GlobalCache interface and its implementations.
Abstract base class for a global entity cache.
A global entity cache is shared across contexts, sessions, and possibly even servers. A concrete implementation is available which uses Redis.
Essentially, this class models a simple key/value store where keys and values are arbitrary
bytesinstances. “Compare and swap”, aka “optimistic transactions” should also be supported.
Concrete implementations can either by synchronous or asynchronous. Asynchronous implementations should return
Futureinstances whose eventual results match the return value described for each method. Because coordinating with the single threaded event model used by
NDBcan be tricky with remote services, it’s not recommended that casual users write asynchronous implementations, as some specialized knowledge is required.
set()but using an optimistic transaction.
Only keys whose values haven’t changed since a preceding call to
watch()will be changed.
Remove entities from the cache.
keys (List[bytes]) – The keys to remove.
Retrieve entities from the cache.
Store entities in the cache.
Redis implementation of the
This is a synchronous implementation. The idea is that calls to Redis should be fast enough not to warrant the added complexity of an asynchronous implementation.
redis (redis.Redis) – Instance of Redis client to use.
Generate a class:RedisCache from an environment variable.
This class method looks for the
REDIS_CACHE_URLenvironment variable and, if it is set, passes its value to
Redis.from_urlto construct a
Redisinstance which is then used to instantiate a