register_type()
Register cls in the process-wide registry, so every cache can store it without pickle.
Usage
register_type(
cls,
*,
name,
encode=None,
decode=None,
)encode(instance) must return a value the codec can already store and decode(value) must give the instance back. A dataclass needs neither: its init=True fields are stored and it is rebuilt with cls(**fields). See TypeRegistry.register for the rules. Call it at import time, in every process that opens the cache.
Examples
from bson import ObjectId
import diskcache_oxide
diskcache_oxide.register_type(ObjectId, name='bson.ObjectId', encode=str, decode=ObjectId)
diskcache_oxide.register_type(Episode, name='tp.Episode') # a dataclass