duck.utils.caching¶
Caching module which leverages the use of diskcache python library. Essential methods mandatory to any Cache class: [set, get, delete, clear]
Package Contents¶
Classes¶
Base class for caching |
|
This class performs speed test of Cache classes. |
|
Manages a cache of files, dynamically creating new files when existing ones reach a size limit. |
|
InMemoryCache with LRU eviction. |
|
Caching which stores cache data in folders with the name of cache keys. |
|
Implementation of caching using the |
API¶
- class duck.utils.caching.CacheBase[source]¶
Base class for caching
- class duck.utils.caching.CacheSpeedTest(repeat: int = 1)[source]¶
This class performs speed test of Cache classes.
Initialization
- instances¶
None
- class duck.utils.caching.DynamicFileCache(cache_dir: str, cache_limit=1000000000.0, cached_objs_limit: int = 128)[source]¶
Bases:
duck.utils.caching.CacheBaseManages a cache of files, dynamically creating new files when existing ones reach a size limit.
Initialization
- _create_new_cache_path()[source]¶
This retrieves new cache path with a unique name using uuid module.
- property cache_obj¶
Returns the Cache object for the current cache file that is not at its limit.
- static get_cache_obj(path: str) duck.utils.caching.PersistentFileCache[source]¶
- class duck.utils.caching.InMemoryCache(maxkeys=None, *_)[source]¶
Bases:
duck.utils.caching.CacheBaseInMemoryCache with LRU eviction.
Initialization
- class duck.utils.caching.KeyAsFolderCache(cache_dir: str)[source]¶
Bases:
duck.utils.caching.CacheBaseCaching which stores cache data in folders with the name of cache keys.
Initialization
- get(key: str) Any[source]¶
This lookup for a folder in cache_dir with the name of the parsed key and returns the cache data.
- static get_cache_obj(path: str) duck.utils.caching.PersistentFileCache[source]¶
- class duck.utils.caching.PersistentFileCache(path: str, cache_size: int = None)[source]¶
Bases:
duck.utils.caching.CacheBaseImplementation of caching using the
diskcachelibraryInitialization
- property closed¶
Checks whether the cache is closed.