oslo_cache.backends package¶
Submodules¶
oslo_cache.backends.dictionary module¶
dogpile.cache backend that uses dictionary for storage
- class oslo_cache.backends.dictionary.DictCacheBackend(arguments: dict[str, Any])¶
Bases:
CacheBackend
A DictCacheBackend based on dictionary.
Arguments accepted in the arguments dictionary:
- Parameters:
expiration_time (real) – interval in seconds to indicate maximum time-to-live value for each key in DictCacheBackend. Default expiration_time value is 0, that means that all keys have infinite time-to-live value.
- delete(key: str) None ¶
Deletes the value associated with the key if it exists.
- Parameters:
key – dictionary key
- delete_multi(keys: Sequence[str]) None ¶
Deletes the value associated with each key in list if it exists.
- Parameters:
keys – list of dictionary keys
- get(key: str) CachedValue | Literal[NoValue.NO_VALUE] | bytes ¶
Retrieves the value for a key.
- Parameters:
key – dictionary key
- Returns:
value for a key or
oslo_cache.core.NO_VALUE
for nonexistent or expired keys.
- get_multi(keys: Sequence[str]) Sequence[CachedValue | Literal[NoValue.NO_VALUE] | bytes] ¶
Retrieves the value for a list of keys.
oslo_cache.backends.etcd3gw module¶
dogpile.cache backend that uses etcd 3.x for storage
- class oslo_cache.backends.etcd3gw.Etcd3gwCacheBackend(arguments: dict[str, Any])¶
Bases:
CacheBackend
- DEFAULT_HOST = 'localhost'¶
Default hostname used when none is provided.
- DEFAULT_PORT = 2379¶
Default port used if none provided (4001 or 2379 are the common ones).
- DEFAULT_TIMEOUT = 30¶
Default socket/lock/member/leader timeout used when none is provided.
- delete(key: str) None ¶
Delete a value from the cache.
- Parameters:
key – String key that was passed to the
CacheRegion.delete()
method, which will also be processed by the “key mangling” function if one was present.
The behavior here should be idempotent, that is, can be called any number of times regardless of whether or not the key exists.
- delete_multi(keys: Sequence[str]) None ¶
Delete multiple values from the cache.
- Parameters:
keys – sequence of string keys that was passed to the
CacheRegion.delete_multi()
method, which will also be processed by the “key mangling” function if one was present.
The behavior here should be idempotent, that is, can be called any number of times regardless of whether or not the key exists.
Added in version 0.5.0.
- get(key: str) CachedValue | Literal[NoValue.NO_VALUE] | bytes ¶
Retrieve an optionally serialized value from the cache.
- Parameters:
key – String key that was passed to the
CacheRegion.get()
method, which will also be processed by the “key mangling” function if one was present.- Returns:
the Python object that corresponds to what was established via the
CacheBackend.set()
method, or theNO_VALUE
constant if not present.
If a serializer is in use, this method will only be called if the
CacheBackend.get_serialized()
method is not overridden.
- get_multi(keys: Sequence[str]) Sequence[CachedValue | Literal[NoValue.NO_VALUE] | bytes] ¶
Retrieves the value for a list of keys.
- set(key: str, value: CachedValue | bytes) None ¶
Set an optionally serialized value in the cache.
- Parameters:
key – String key that was passed to the
CacheRegion.set()
method, which will also be processed by the “key mangling” function if one was present.value – The optionally serialized
CachedValue
object. May be an instance ofCachedValue
or a bytes object depending on if a serializer is in use with the region and if theCacheBackend.set_serialized()
method is not overridden.
See also
CacheBackend.set_serialized()
- set_multi(mapping: Mapping[str, CachedValue | bytes]) None ¶
Set multiple values in the cache.
- Parameters:
mapping – a dict in which the key will be whatever was passed to the
CacheRegion.set_multi()
method, processed by the “key mangling” function, if any.
When implementing a new
CacheBackend
or cutomizing viaProxyBackend
, be aware that when this method is invoked byRegion.get_or_create_multi()
, themapping
values are the same ones returned to the upstream caller. If the subclass alters the values in any way, it must not do so ‘in-place’ on themapping
dict – that will have the undesirable effect of modifying the returned values as well.If a serializer is in use, this method will only be called if the
CacheBackend.set_serialized_multi()
method is not overridden.Added in version 0.5.0.
oslo_cache.backends.memcache_pool module¶
dogpile.cache backend that uses Memcached connection pool
- class oslo_cache.backends.memcache_pool.PooledMemcachedBackend(arguments: dict[str, Any])¶
Bases:
MemcachedBackend
Memcached backend that does connection pooling.
This memcached backend only allows for reuse of a client object, prevents too many client object from being instantiated, and maintains proper tracking of dead servers so as to limit delays when a server (or all servers) become unavailable.
This backend doesn’t allow to load balance things between servers.
Memcached isn’t HA. Values aren’t automatically replicated between servers unless the client went out and wrote the value multiple time.
The memcache server to use is determined by python-memcached itself by picking the host to use (from the given server list) based on a key hash.
- property client: ClientProxy¶
Return the memcached client.
This uses a threading.local by default as it appears most modern memcached libs aren’t inherently threadsafe.
- client_pool: MemcacheClientPool¶