fictive.cache.mixins module

fictive.cache.mixins

Optional mix in features for an AbstractCache

Classes

RLockingMixin

Uses a re-entrant lock to protect any mutations to the cached value

ValidatingMixin

Stored values are considerd a cache miss if they fail validation

class fictive.cache.mixins.RLockingMixin(*args, reentrant_lock, acquire_args: Iterable = None, acquire_kwargs: Mapping = None, **kwargs)[source]

Bases: object

Uses a re-entrant lock to protect any mutations to the cached value

exception CacheLockError[source]

Bases: fictive.cache.abstract.AbstractCache.CacheWriteError

Raised when a cache lock could not be acquired

__init__(*args, reentrant_lock, acquire_args: Iterable = None, acquire_kwargs: Mapping = None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

property acquire_params

Read-only access

bind_acquire_params(*args, **kwargs)[source]

Bind the parameters that will be used for the lock acquire method

class fictive.cache.mixins.ValidatingMixin(*args, validate_impl=None, **kwargs)[source]

Bases: object

Stored values are considerd a cache miss if they fail validation

Validation is “reconsidered” if a fetch fails

exception CacheInvalidError[source]

Bases: fictive.cache.abstract.AbstractCache.CacheMissError

raised when a cached value is invalid and should be disregarded

__init__(*args, validate_impl=None, **kwargs)[source]
Parameters

validate_impl – callable that determines whether a value is valid

property validate_impl

allow for overriding _validate_impl after initialization