This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
CacheTagHelper should not depend on IMemoryCache #3867
Closed
Description
IMemoryCache
is a perfect match for single node scenarios in CacheTagHelper but it breaks if the website runs on more nodes, as each node would return different contents. The issue here is that there is no way to change it.
I think it would be better to either:
- Depend on
IDitributedCache
as the default implementation usesIMemoryCache
which means it would work the same as today on a single instance, and not be broken on multiple instances. - Or even better, define a custom interface for extensibility reasons so that each customer could decide how to store the cached tags: explicitly
IMemoryCache
,IDistributedCache
or another implementation. Each site is different, and locking down the cache tag storage might be an issue. And having the to share the same implementation for controllers and tags might not make sense either.
A different approach would be to use a message bus implementation to invalidate IMemoryCache
entries across nodes, but I don't think it's been planned either.
/cc @NTaylorMullen