Caching Block Not Firing ICacheItemRefreshAction

Topics: Caching Application Block
Jan 24, 2007 at 1:25 AM
I don't know if this is the best place to post issues w/ the P&PEL seeing as there isn't much activity, but here goes.

I'm doing some high level testing with the caching block, namely just proactively caching some large data structures when the app first fires up. I'm setting an expiration time, and have a refreshAction class set up to refetch/cache the items when they expire. Initially all was working fine, however recently the refreshAction classes aren't being called when the items expire...it almost looks like the threads are getting locked up.

Regardless, some pointers would be greatly appreciated.
Jan 24, 2007 at 7:12 PM
This is the right place. The forums just recently moved here from GDN with the anticipated release of Enterprise Library 3.0, so it's not really that quiet :)

It sounds like you are doing everything correct. When you add an item to the cache you would just specify an ICacheItemRefreshAction as you are doing. For example:

string test = "test";

CacheManager cm = CacheFactory.GetCacheManager();
cm.Add("test", test, CacheItemPriority.Normal, new StringCacheRefreshAction(), new SlidingTime(TimeSpan.FromMinutes(5));

When the object is removed from the cache you will get notification:

public class StringCacheRefreshAction : ICacheItemRefreshAction
{
public void Refresh(string key, object expiredValue, CacheItemRemovedReason removalReason)
{
// ...
}
}

There are no known bugs at this time, so the best I can recommend is to tweak the code and settings and see if it makes a difference.

You may also want to look into multiple cache managers, one for each object type, and perhaps multiple classes that implement ICacheItemRefreshAction to see if the problem is particular to a object type, etc.

The documentation has pretty good information on it, but again, it appears you grasp the idea and it is particular to something in your application.

Errors like that are frustrating to debug. I would rather things just work or not work :)

Regards,

Dave

_________________________

David Hayden
Microsoft MVP C#
http://www.davidhayden.com/
Jul 22, 2010 at 12:18 PM

The refresh method call depends on "expirationPollFrequencyInSeconds" attribute value in the config file, not always when cache items expired.

Regards,

Suresh.C