I have an ordered dictionary where the values are of a custom type object (for example datetime.datetime) and I want to cache it to Redis. What is a good and secure way to store it because, as far as I am aware, there is no way to store custom objects to Redis?
An basic example of my ordered dictionary and my object could be this :
import datetime
from dataclasses import dataclass
from collections import OrderedDict
@dataclass(frozen=True)
class Prediction:
_id: int
risk: str
timestamp: datetime.datetime
history =OrderedDict([("old",Prediction(_id=1,risk="low",timestamp=datetime.datetime(2022, 5, 13, 10, 10, 30, 568388))),("new",Prediction(_id=2,risk="high",timestamp=datetime.datetime(2022, 5, 13, 12, 4, 9, 568388))) ])
how can this be processed, stored and retrieved from Redis?