store.cache.backends.filecache

Module Contents

Classes

FileCache

class store.cache.backends.filecache.FileCache(cache_configuration: Any)

Bases: e3.store.cache.backends.base.Cache

cache_suffix = '.cache'
clear() None

Remove all values from the cache at once.

delete(uid: str) None

Delete a resource from the cache.

Do nothing if the uid does not exist. :param uid: the resource uid

_create_cache_dir() None
uid_to_file(uid: str) str

Convert a resource uid to a cache file path.

This backend assumes that the uid is a safe value for a file name. :param uid: the resource uid

static _is_expired(fd: IO[bytes]) bool

Determine if an open cache file has expired.

Automatically delete the file if it has passed its expiry time.

get(uid: str, default: Any = None) Any

Fetch a given resource from the cache.

If the resource does not exist, return default, which itself defaults to None. :param uid: the resource uid :param default: the default value if not found

set(uid: str, value: Any, timeout: int = DEFAULT_TIMEOUT) bool

Set a value in the cache.

Parameters:
  • uid – the cache entry uid

  • value – the object to cache

  • timeout – timeout to use for caching this value, otherwise the default cache timeout will be used.

Returns:

True if the value is set, False in case of failure