Classes to add key prefix and stats to cachetools classes and use redis and memcached as storage backends, and other cache-related utils.
For our purpose, a cache is a key-value store, aka a dictionary, possibly with
some constraints on keys (type, size) and values (size, serialization).
This module provides new caches, wrappers and other utilities suitable to use
with cachetools.
RedisCacheallows to see a Redis server as a python cache by wrapping aredis.Redisinstance.MemCacheddoes the same for a Memcached server. The utility classJsonSerdeis a convenient JSON serializer-deserializer class for Memcached.DictCachea very simpledictcache.
PrefixedCache,PrefixedMemCachedandPrefixedRedisCacheadd a prefix to distinguish sources on a shared cache.StatsCache,StatsMemCachedandStatsRedisCacheadd ahits()method to report the cache hit rate.LockedCacheuse a (thread) lock to control cache accesses.TwoLevelCacheallows to combine two caches.DebugCacheto trace cache calls usinglogging.
cacheddecorator: a cachetools replacement which allows to test if a function result is in cache, and to delete such an entry.cacheFunctionsandcacheMethods: add caching to functions or methods.
This code is Public Domain.
All software has bug, this is software, hence… Beware that you may lose your hairs or your friends because of it. If you like it, feel free to send a postcard to the author.
See the documentation, sources and issues on GitHub.
See packages on PyPI.