Open Stargateur opened 4 years ago
After testing around I think both could be nice to have.
In order of my thoughts:
(3): I think we should avoid implementing Serialize/Deserialize since we'd have to maintain that contract between library versions and that'd be a major pain.
(2): I'm not sure either, but seems like it might be more complicated than it's worth
(1. & 4): I think we should add a .iter
method to the Cached trait for returning all cached keys and values in an unspecified order (as if you were pulling the values from a hashmap), and then implement std::iter::FromIterator
for each cache store. I think it's reasonable and okay to lose internal metadata (like time) when going to/from an iterator, and leave that as an implementation detail of each cache type, e.g. SizedCache returns an iterator in the order of oldest to newest and its FromIterator implementation assumes the same oldest to newest ordering so it can simply cache_set
all the values in order.
I think we should add a .iter method to the Cached trait for returning all cached keys and values
Yes that my first though but that not easy as its look see https://github.com/rust-lang/rust/issues/44265. I don't think it's currently possible.
I need to serialize the cache: