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]