fictive.cache.abstract module¶
Provides a base class for automatically managed read-through cacheing behavior
Subclasses should provide a backing store and methods for fetching a new value
Classes
An abstract class representing a single-level cache interface |
-
class
fictive.cache.abstract.AbstractCache(*args, fetch_impl=None, **kwargs)[source]¶ Bases:
objectAn abstract class representing a single-level cache interface
This interface provides four basic actions (
_fetch_impl,_read_impl,_set_impl, and_delete_impl) for implementing the interaction between the cache interface and a backing store. Subclasses for specific cache backing store types should generally override one or more of these methods.Additionally, each of the four actions has an associated ‘private’ dispatch method (
_dispatch_fetch,_dispatch_read,_dispatch_set, and_dispatch__delete, respectively) that controlls when and how the interface methods will be invoked. Mixins or subclasses that want to supplement or override generic cache behavior, or alter the ways in which the basic actions interoperate, would probably want to override one or more of these methods.The interface also provides a
valueanddeletemethods by which client code can access and clear the cached value, and afetchdecorator by which client code can set the callable that will ‘refresh’ the cache from an external value-
ANY_VALUE= <object object>¶
-
exception
CacheFetchError[source]¶ Bases:
fictive.cache.abstract.AbstractCache.CacheErrorRaised when an external value could nto be obtained
-
exception
CacheMissError[source]¶ Bases:
fictive.cache.abstract.AbstractCache.CacheErrorRaised when a value is not present in the cache
-
exception
CacheWriteError[source]¶ Bases:
fictive.cache.abstract.AbstractCache.CacheErrorRaised when a value cannot be written to the cache
-
IDENTITY_TRANSFORM= <fictive.transform.Transform object>¶
-
VALUE_TRANSFORM: fictive.transform.Transform = <fictive.transform.Transform object>¶ Transformapplied to present values to calling code
-
__init__(*args, fetch_impl=None, **kwargs)[source]¶ - Parameters
fetch_impl (callable) – if provided, this callable will be invoked by
_dispatch_fetch(rather than the class’s_fetch_implmethod). The call siganture offetch_implmust accept this instance as a first positional argument.
-
delete_value(cache_value, *args, **kwargs)[source]¶ interface to delete the stored value if it is equal to
cache_value
-
property
fetch_impl¶ allow for overriding
_fetch_implafter initialization
-
get_value(*args, **kwargs)[source]¶ client interface to access the cache; automatically fetches if needed
-
property
value¶ simple property-based interface for default cache behavior
-