After you’ve set the environment variable, then you just need to import
caches in your code:

importcaches

Caches will take care of parsing the url and creating the redis
connection, automatically, so after the import Caches will be ready to
use.

Interface

All caches caching classes have a similar interface, they take passed in
constructor *args and concat them to create a key:

c=KeyCache('foo','bar','che')printc.key# foo.bar.che

If you would like to init your cache object with a value, use the
data**kwarg:

c=KeyCache('foo',data="boom!")printc.key# fooprintc# "boom!"

Each caches base caching class is meant to be extended so you can set
some parameters:

serialize – boolean – True if you want all values pickled,
False if you don’t (ie, you’re caching ints or strings or something).

prefix – string – This will be prepended to the key args you
pass into the constructor.

ttl – integer – time to live, how many seconds to cache the
value. Set to like 2 hours by default, 0 means live forevor.

connection_name – string – if you have more than one caches
dsn then you can use this to set the name of the connection you want
(the name of the connection is the #connection_name fragment of a
dsn url).

classMyIntCache(KeyCache):serialize=False# don't bother to serialize values since we're storing intsprefix="MyIntCache"# every key will have this prefix, change to invalidate all currently cached valuesttl=7200# store each int for 2 hours

CounterCache

Decorator

Caches exposes a decorator to make caching the return value of a
function easy. This only works for KeyCache derived caching.

The cached decorator can accept a caching class and also a key
function (similar to the python built-in “sorted()`
function <http://docs.python.org/2/library/functions.html#sorted>`__ key
argument), except caches key argument returns a list that can be passed
to the constructor of the caching class as *args.