Cement defines a cache interface called ICache, but does not implement caching by default. The documentation below references usage based on the interface and not the full capabilities of any given implementation.

The following cache handlers are included and maintained with Cement:

Please reference the ICache interface documentation for writing your own cache handler.

General Usage

For this example we use the Memcached extension, which requires the pylibmc library to be installed, as well as a Memcached server running on localhost.



extensions = memcached

# comma separated list of hosts to use
hosts =

# time in milliseconds
expire_time = 300

from import CementApp

with CementApp('myapp') as app:
    # run the application

    # set a cached value
    app.cache.set('my_key', 'my value')

    # get a cached value

    # delete a cached value

    # delete the entire cache