vendredi 24 novembre 2017

HttpContext.Current.Cache.Insert RemovedCallback not work

i need to have a callback after cache item remove (for log a summary of cach item in db), i write this:

var onRemove = new CacheItemRemovedCallback(RemovedCallback);
 HttpContext.Current.Cache.Insert(key, cachedData, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1), CacheItemPriority.Normal, onRemove);

this callback method (RemovedCallback) dosn't called after insert! but it's called after i change this cache item value , like this:

HttpContext.Current.Cache[key] = cachedData;

i dont know what this happen! even when i remove itHttpContext.Current.Cache.Remove(key); , this method dosn't called! (i have a breakPoint in this method that not working !). my secund question is :i set 1 minute to keep this item in cach! but it dosn't remove after this priod! why?

"sory for my bad english, i'm training"




Aucun commentaire:

Enregistrer un commentaire