Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install eea.cache

How to install eea.cache

  1. Download and install ActivePython
  2. Buy and install the Business Edition license from account.activestate.com
  3. Open Command Prompt
  4. Type pypm install eea.cache

eea.cache contains builds that are only available via PyPM when you have a current ActivePython Business Edition subscription.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
4.2
4.3Never BuiltWhy not?
4.2 Available View build log
4.0 Available View build log
Windows (64-bit)
4.2
4.3Never BuiltWhy not?
4.2 Available View build log
4.0 Available View build log
Mac OS X (10.5+)
4.2
4.3Never BuiltWhy not?
4.2 Available View build log
4.0 Available View build log
Linux (32-bit)
4.3
4.3 Available View build log
4.2 Available View build log
4.0 Available View build log
Linux (64-bit)
4.3
4.3 Available View build log
4.2 Available View build log
4.0 Available View build log
 
License
GPL
Depended by
http://ci.eionet.europa.eu/job/eea.cache-www/badge/icon http://ci.eionet.europa.eu/job/eea.cache-plone4/badge/icon

Introduction

This package combines the features from lovely.memcached and plone.memoize.ram. It provides a decorator and utility for Memcaches at EEA. The decorator allows you set dependencies known by eea.cache

Note

This add-on doesn't do anything by itself. It needs to be integrated by a developer within your own products. For reference you can check the eea.app.visualization package.

Installation

zc.buildout

If you are using zc.buildout and the plone.recipe.zope2instance recipe to manage your project, you can do this:

  • Update your buildout.cfg file:

    parts +=
      libevent
      memcached
      memcached-ctl
    
    effective-user = zope-www
    
    [instance]
    ...
    eggs =
      ...
      eea.cache
    
    zcml =
      ...
      eea.cache-overrides
    
    
    [libevent]
    recipe = zc.recipe.cmmi
    url = http://www.monkey.org/~provos/libevent-1.4.8-stable.tar.gz
    
    [memcached]
    recipe = zc.recipe.cmmi
    url = http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
    extra_options = --with-libevent=${libevent:location}
    
    [memcached-ctl]
    recipe = lovely.recipe:mkfile
    path = ${buildout:bin-directory}/memcached
    mode = 0755
    content =
     #!/bin/sh
     export LD_LIBRARY_PATH=${libevent:location}/lib
    
     PIDFILE=${memcached:location}/memcached.pid
        case "$1" in
          start)
           ${memcached:location}/bin/memcached -d -u ${buildout:effective-user} -P $PIDFILE
            ;;
          stop)
            kill `cat $PIDFILE`
            ;;
          restart|force-reload)
            $0 stop
            sleep 1
            $0 start
            ;;
          *)
            echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
            exit 1
            ;;
        esac
    
  • Re-run buildout, e.g. with:

    $ bin/buildout -c buildout.cfg
    
  • Restart memcache and Zope:

    $ bin/memcached restart
    $ bin/instance restart
    

Dependencies

EEA Cache has the following dependencies:
  • Plone 4+

Source code

Latest source code (Zope 2 compatible):

Cache decorator

>>> def key(method, self):
...     return method.__name__
>>> from eea.cache import cache
>>> @cache(key, dependencies=["frontpage"])
... def myMethod(num):
...     return num*num

Lets clear any running memcache

>>> from eea.cache.event import InvalidateCacheEvent
>>> from zope.event import notify
>>> notify(InvalidateCacheEvent(raw=True, dependencies=['frontpage']))

Our myMethod will now be cached with the key returned from the method 'key' and with dependency 'frontpage'.

>>> myMethod(2)
4
>>> myMethod(3)
4
>>> notify(InvalidateCacheEvent(raw=True, dependencies=['frontpage']))
>>> myMethod(3)
4

Cache lifetime

By default your content is cached in memcache for one hour (3600 seconds). You can change this by adding an int property within: ZMI > portal_properties > site_properties called memcached_defaultLifetime and set it's value to 86400 (one day) for example.

Cache lifetime override per key

Starting with eea.cache 5.1 you can also pass a lifetime key with the duration in seconds which will override the defaultLifetime either given from the portal property or the default one from lovely.memcached of 3600 seconds

ex: in order to cache the result only for 4 minutes
>>> @cache(key, dependencies=["frontpage"], lifetime=240)
... def myMethod(num):
...     return num*num

Funding and project management

EEA - European Environment Agency (EU)

Changelog

6.1 - (2013-06-17)
  • Cleanup: Use logger.debug instead of logger.info for debug messages [avoinea]
6.0 - (2013-05-20)
  • Feature: Removed lovely.memcached dependency [voineali refs #14343]
5.1 - (2013-02-04)
  • Feature: added information for contributors [ciobabog refs #13892]
  • Feature: added ability to pass a lifetime key to the cache decorator in order to cache it for a determined period different from the default lifetime [ichimdav #13677]
  • Upgrade step: (optional) Within ZMI > portal_properties > site_properties add an int property called memcached_defaultLifetime and set it's value to 86400 (one day) or any value that fits your needs.
  • Feature: Ability to set memcached default lifetime, which by now was hardcoded to one hour (3600 seconds) [voineali refs #13677]
5.0 - (2012-10-08)
  • Change: Updated README and egg's metadata [voineali refs #5434]
4.3 - (2012-07-13)
  • Bug fix: fixed markup of HISTORY.txt file [ciobabog refs #5231]
4.2 - (2012-02-06)
  • no changes
4.0 - (2011-11-07)
  • Feature: Plone 4.x compatible release [ghicaale #4309]
0.3 - (2010-11-22)
  • Bug fix: fixed tests namespace in order to be used within hudson [voineali #3821]
0.2 - (2010-11-10)
  • Bug fix: added fake memcache client in order to fix broken doctests [voineali]
0.1 - (2009-11-10)
  • Initial release

Subscribe to package updates

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.