CacheToolsUtils
Classes to add key prefix and stats to cachetools classes and use redis and memcached as storage backends, and other cache-related utils.
Module Contents
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
.
Cache classes
RedisCache
allows to see a Redis server as a python cache by wrapping aredis.Redis
instance.MemCached
does the same for a Memcached server. The utility classJsonSerde
is a convenient JSON serializer-deserializer class for Memcached.DictCache
a very simpledict
cache.
Wrappers to extend cache capabilities
PrefixedCache
,PrefixedMemCached
andPrefixedRedisCache
add a prefix to distinguish sources on a shared cache.StatsCache
,MemCached
andRedisCache
add ahits
method to report the cache hit rate,stats
to report statistics andreset
to reset statistics.LockedCache
use a (thread) lock to control cache accesses.TwoLevelCache
allows to combine two caches.DebugCache
to trace cache calls usinglogging
.
Cache utilities
cached
decorator: a cachetools replacement which allows to test if a function result is in cache, and to delete such an entry.cacheFunctions
andcacheMethods
: add caching to functions or methods.json_key
andhash_json_key
: JSON-based cache key serialization functions
License
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.
More
See the documentation, sources and issues on GitHub.
See packages on PyPI.
- Tutorial
- Recipes
- Explanations
- Reference
- Versions
- TODO or NOT TODO…
- 9.2 on 2024-11-29
- 9.1 on 2024-11-28
- 9.0 on 2024-10-27
- 8.6 on 2024-08-03
- 8.5 on 2024-02-03
- 8.4 on 2024-01-20
- 8.3 on 2023-11-12
- 8.2 on 2023-08-27
- 8.1 on 2023-08-27
- 8.0 on 2023-08-26
- 7.0 on 2023-06-17
- 6.0 on 2023-03-19
- 5.1 on 2022-11-12
- 5.0 on 2022-09-11
- 4.3 on 2022-09-07
- 4.2 on 2022-08-05
- 4.1 on 2022-08-05
- 4.0 on 2022-03-13
- 3.0 on 2022-03-06
- 2.0 on 2022-02-24
- 1.1.0 on 2022-01-30
- 1.0.0 on 2022-01-29
- 0.9.0 on 2022-01-29
- API Reference