Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple serialization logic from CacheBackend classes
Reworked the means by which values are serialized and deserialized from backends, and provided for custom serialization of values. Added the :paramref:`.CacheRegion.serializer` and :paramref:`.CacheRegion.deserializer` parameters which may be set to any serializer. Serialization and deserialization now take place within the :class:`.CacheRegion` so that backends may now assume string values in all cases. This simplifies the existing backends and also makes custom backends easier to write and maintain. Additionally, the serializer is now applied to the user-defined value portion of the :class:`.CachedValue` and not to the metadata or other portions of :class:`.CachedValue` object itself, so the serialized portion is effectively a "payload" within the larger :class:`.CachedValue` structure that is passed as part of the larger string format. The overall format is a separate JSON of the cached value metadata, followed by the serialized form. This allows for end-user serialization schemes that are hardwired to the values themselves without the need to serialize dogpile's internal structures as well. Pull request courtesy Alessio Bogon. As this is a major refactor and we are Python 3, adds a significant start to pep-484 annotations. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Closes: #191 Pull-request: #191 Pull-request-sha: 06f449c Change-Id: I71bce715c79b455b88aa9c17e626e929f451e1d9
- Loading branch information