bucketcache.backends¶
-
class
bucketcache.backends.
Backend
(value, expiration_date=None, config=None)[source]¶ Bases:
represent.core.ReprMixin
,object
Abstract base class for backends.
Classes must implement abstract attributes:
and abstract methods:
-
binary_format
¶ Return True or False to indicate if files should be opened in binary mode before passing to
from_file()
anddump()
.
-
default_config
¶ Associated
bucketcache.config.Config
class. Instantiated without arguments to create default configuration.
-
file_extension
¶ File extension (without full stop) for files created by the backend.
-
classmethod
check_concrete
(skip_methods=False)[source]¶ Verify that we’re a concrete class.
Check that abstract methods have been overridden, and verify that abstract class attributes exist.
Although ABCMeta checks the abstract methods on instantiation, we can also do this here to ensure the given Backend is valid when the Bucket is created.
-
has_expired
()[source]¶ Determine if value held by this instance has expired.
Returns False if object does not expire.
-
classmethod
from_file
(fp, config=None)[source]¶ Class method for instantiating from file.
Parameters: - fp (file-like object) – File containing stored data.
- config (
Config
) – Configuration passed fromBucket
Note
Implementations should ensure config is valid as follows:
config = cls.valid_config(config)
Warning
If the appropriate data cannot be ready from fp, this method should raise
BackendLoadError
to informBucket
that this cached file cannot be used.
-
dump
(fp)[source]¶ Called to save state to file.
Parameters: fp (file-like object) – File to contain stored data. Attributes value and expiration_date should be saved, so that
from_file()
can use them.
-
-
class
bucketcache.backends.
PickleBackend
(value, expiration_date=None, config=None)[source]¶ Bases:
bucketcache.backends.Backend
Backend that serializes objects using Pickle.
-
default_config
¶ alias of
PickleConfig
-
-
class
bucketcache.backends.
JSONBackend
(value, expiration_date=None, config=None)[source]¶ Bases:
bucketcache.backends.Backend
Backend that stores objects using JSON.
-
default_config
¶ alias of
JSONConfig
-
-
class
bucketcache.backends.
MessagePackBackend
(*args, **kwargs)[source]¶ Bases:
bucketcache.backends.Backend
Backend that stores objects using MessagePack.
-
default_config
¶ alias of
MessagePackConfig
-