store.cache.backends.filecache

File-based cache backend for store.

Module Contents

Classes

FileCache

File-based cache backend implementation.

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

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

File-based cache backend implementation.

Variables:

cache_dir – directory where cache files are stored

cache_suffix = '.cache'
clear() None

Clear.

delete(uid: str) None

Delete.

_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.

Parameters:

uid – the resource uid

Returns:

path to the cache file for the given 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.

Parameters:

fd – open file descriptor to check

Returns:

True if the cache file has expired, False otherwise

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

Fetch a given resource from the cache.

Parameters:
  • uid – the resource uid

  • default – the default value if not found

Returns:

the cached value or default if not found or expired

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

Returns:

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