Open sfmskywalker opened 6 years ago
I didn't answer earlier because this is something which has been asked several times as it is related to cache dependency management. Which is a feature CM doesn't provide. Added it to the backlog. But for starters, adding change monitors to distributed cached keys will not work very well or will be very complex to implement...
The API currently has support for providing an expiration date (plus various modes). What would be nice however is to also have a way to provide change monitors (a la ObjectCache / MemoryCache) / or "volatile tokens" (as implemented in Orchard) that allow an application to trigger the change monitor / volatile token. Examples of monitors/tokens would be:
The way this would be used is as follows:
CacheItem
.SignalMonitor
.signalMonitor.Trigger()
is called, which causes the cache to evict or expire the associated cache item.This I think would be a very powerful addition, making cache eviction a breeze. Currently, one has to keep references to cache keys in order to evict them; with the monitors, that is no longer necessary.