Caching Application Block with FileDependency

Topics: Caching Application Block
May 4, 2010 at 6:56 AM
Hi experts. My real world services, which are using the cache, have a bunch of users logging in at uneven time and are logged inn for max 10 minutes. So I cache personal data in a separate cache store with an absolute time for 10 minutes. I’m using the null backing store. Now we are going to move the services to a new hardware configuration with load balancing. I’m fully aware that the Caching Application Block does not support distributed cache. But my requirements for updating cached items are low. About 5 objects per customer can be updated. So my thought was, can I use FileDependency expiration policy on those 5 objects per customer. Name the file “CacheKey”.txt and have the files in a common share. I Also decreased expirationPollFrequencyInSeconds to 10 which is probably ok for my setting. I created a test project to test this setting. On adding a FileDependency I create the text file. And in the update methods I clear the cached item, in the my implementation of ICacheItemRefreshAction for FileDependencies I delete the “CacheKey.txt”, which unfortunately gives me this IO exception “The process cannot access the file 'C:\Data\Cache\some_key.txt' because it is being used by another process.” Also I can’t edit the file directly in notepad either. Opening the file gives me “The process cannot access the file because it is being used by another process”. My question is, shall the FileDependency look the file it depends on? Does anyone have a suggestion to how to use CachingApplicationBlock in such a setting? Regards Frode
May 4, 2010 at 8:56 PM

You mean does the FileDependency locks the file?  Looking at the code, I don't see any places where it does lock the file. 

The error message you posted refers to a different file - som_key.txt.  Is it really different from the one which you specified as the file dependency? 

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 5, 2010 at 8:25 AM

Hi.

 

The key name where just example, in my code I have the file AccountList.txt and key AccountList.

I can send you the complete code if you want to.

 

Mvh.

Frode

May 5, 2010 at 10:28 AM

I tried to repro but I wasn't able to so yes, might be a good thing if I look at your code.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com