Paolo ponzano - 60 - Sep 12, 2014

Hello Demis, I was wondering if it’s possible to create an httphandler to handle cached items… as far I’ve seen there’s no property exposed inside the ICacheClient class that permits me to iterate through …cna you help me on this? Thanks

There is no API that lets you that lets you iterate all keys, each cache provider works differently and any key could be used. Ideally you should be treating the cache like a transient store, where the items you want to expire should be specified with a future Date or TimeSpan period when creating the cache so it expires automatically.

paolo ponzano:

Demis It would be nice to have the possibility of invalidate a cache item before it’s natural expiration period…consider a simple example… I’ve a dropdown with some products (data cached) I’ve expiration set in 5 hours and I’ve added on DB a new product I wish to show on the dropdown… I can reset the whole cache provider (appPool, Redis, whatelse) or to wait the xxx minutes…

Jeff Gabhart:

I don’t know if this is the best way to address this idea, but I end up storing the product twice. Once by itself on its own key, and then once within a list that contains all products. Then invalidate the single key whose Id you know and also invalidate the list so it pulled fresh the next time.