Items removed from cache without a reason, why? (CacheItemRemovedReason)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Angela DiPierro
    New Member
    • Nov 2010
    • 1

    #1

    Items removed from cache without a reason, why? (CacheItemRemovedReason)

    Hi,
    I've developed a timerjob that adds a lot of XmlDocument objects to the cache of a web application.
    I've used this code to add the object to the cache:

    Code:
    Cache.Insert(XMLKey, doc, dependency, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(24, 0, 0), System.Web.Caching.CacheItemPriority.Normal, onRemove);
    Parameters represent the following:
    XMLKey --> The cache key used to reference the object
    doc --> the XmlDocument object
    dependency --> the file dependency for the item to invalid the cache
    System.Web.Cach ing.Cache.NoAbs oluteExpiration --> absolute expiration, in this case the cache should never expire
    new TimeSpan(24, 0, 0) --> sliding expiration, in this case the cache should expire after 24 hours
    System.Web.Cach ing.CacheItemPr iority.Normal --> Cache item priority
    onRemove --> a delegate (CacheItemRemov edCallback) called when the item is removed from the cache for any reason

    I need to keep all the objects in cache until their expiration (24 hours), but they are removed automatically after one or two hours!
    I use the delegate onRemove to understand the reason of this behavior. In order to do this I print out the CacheItemRemove dReason value and this is REMOVED.
    On msdn I've found this about REMOVED as value of CacheItemRemove dReason property:
    REMOVED --> The item is removed from the cache by a Remove method call or by an Insert method call that specified the same key.
    The point is that I do not call any Insert method with the same key neither any explicit Cache.Remove() method. So I don't understand what causes the removing of all my items. :S

    Any idea about this issue? Please, could anyone help me?

    Thanks a lot.
    Angela
    Last edited by NeoPa; Nov 2 '10, 05:36 PM. Reason: Please use the [code] tags provided.
Working...