TtlCache and testing
As far as I undestand, TtlCache use std::time::{Duration, Instant} without any indirection layer.
This makes it trickier to [unit-]test the code without waiting.
Shall there be some additional testing version of TtlCache that has overridable timer?
Great point. I'll look into doing this. Do you have any thoughts on what you would like the general API to look like?
I was thinking about this. I think I might implement this as a generic type parameter. By default it will be an implementation that directly calls Duration/Instant but a user may optionally implement a struct that can mock it out.
Before I make my own trait, do you know of any good crates that define the abstraction? I'd rather just pull in something other people are already using.
I usually find that fake_clock is a nice solution if you can apply it to your use-case.
This blog post is a good example of it.