speasy.core.cache.cache module

class speasy.core.cache.cache.Cache(cache_path: str = '', cache_type: str = 'Cache')[source]

Bases: object

add(key, value, expire=None, tag: str | None = None)[source]
cache_file
cache_type
disk_size()[source]
drop(key)[source]
drop_matching_entries(pattern: str | Pattern)[source]

Drop all cache entries that match a given pattern

Parameters:
patternstr or re.Pattern

The pattern to match cache keys against

evict_tag(tag: str)[source]
get(key, default_value=None)[source]
incr(key, delta=1, default=0)[source]
keys()[source]
lock(key: str)[source]
set(key, value, expire=None, tag: str | None = None)[source]
stats()[source]
transact(key: str | None = None)[source]

Open a transaction context.

For a single Cache the key argument is ignored. For a FanoutCache the transaction is per-shard and key selects the shard — atomicity only applies within that shard, so all operations in the block must target the same shard key.

property version
class speasy.core.cache.cache.CacheItem(data, version, lifetime=None)[source]

Bases: object

bump_creation_time() CacheItem[source]
is_expired() bool[source]
speasy.core.cache.cache.delete_migration_backups() List[str][source]

Delete legacy diskcache backups left over from migrating to sciqlop-cache.

Safe to call at any time: only removes the <path>.diskcache.backup directories created by the one-time migration, never a live cache.

Returns:
List[str]

Paths that were actually deleted.

speasy.core.cache.cache.migration_backups() List[str][source]

List legacy diskcache backups left over from migrating to sciqlop-cache.

Returns:
List[str]

Paths to backup directories that currently exist on disk.