FusionCache
FusionCache copied to clipboard
[FEATURE] Improve testing integration via fakes
Problem
I want to write tests that actually cover the caching and can use TimeProvider to jump forward in time to not have to wait for the expiration. I also would like to see if failsafe was triggered or not, etc. But I can't use a real distributed cache in the tests.
Currently - as far as I know - there is only support for in memory cache + NullDistributedCache, which completelly disables the L2 cache.
Solution
A fake distributed cache, that:
- stores values in a concurrent dictionary
- uses TimeProvider to reason about expiration
- remembers all cache reads/write calls
- has methods to get the remembered reads/writes
- has methods to get the metadata of a cache value (when does it expire, tags, etc.)
- has a reset method (to revert to an empty state between tests)
If possible something similar for the in memory cache.
Alternatives
I couldn't come up with good alternatives.