bucketcache.keymakers

class bucketcache.keymakers.KeyMaker[source]

Bases: represent.core.ReprMixin, object

KeyMaker abstract base class.

make_key(obj)[source]

Make key from passed object.

Parameters:obj – Any Python object.
Yields:bytes of key to represent object.
class bucketcache.keymakers.StreamingDefaultKeyMaker(sort_keys=True)[source]

Bases: bucketcache.keymakers.DefaultKeyMaker

Subclass of DefaultKeyMaker that uses a temporary file to save memory.

class bucketcache.keymakers._AnyObjectJSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

Serialize objects that can’t normally be serialized by json.

Attempts to get state will be done in this order:

  • o.__getstate__()
  • Parameters from o.__slots__
  • o.__dict__
  • repr(o)
class bucketcache.keymakers.DefaultKeyMaker(sort_keys=True)[source]

Bases: bucketcache.keymakers.KeyMaker

Default KeyMaker that is consistent across Python versions.

Uses _AnyObjectJSONEncoder to convert any object into a string representation.

Parameters:sort_keys (bool) – Sort dictionary keys for consistency across Python versions with different hash algorithms.
class bucketcache.keymakers.StreamingDefaultKeyMaker(sort_keys=True)[source]

Bases: bucketcache.keymakers.DefaultKeyMaker

Subclass of DefaultKeyMaker that uses a temporary file to save memory.