Ent Lib caching 1.1 to 4.1 question

Topics: Caching Application Block
Mar 19, 2010 at 12:35 AM
Edited Mar 19, 2010 at 7:33 PM

Hi All,

I am going through an Enterprise Library caching version 1.1 to 4.1 migration project.

I have a cache manager that is using file dependency in Ent Lib cache manager Add method which takes an array of ICacheItemExpiration as one of its input parameters.

the problem is the old code is using an instance of FileDependencyEx class which seems it is deprecated in 4.1, the constructor looks like this FileDependencyEx  (filename, expirationCheckInterval)

below is my old and new converted code.

Old Code :

new FileDependencyEx[] { new FileDependencyEx(filename, WebConfig.FileDependencyExpirationSec) }

I have replaced this code with  

New Code:

   ICacheItemExpiration[] expirationPolicies = new ICacheItemExpiration[] 

                                                        { 

                                                        new FileDependency(filename ),

                                                        new NeverExpired()

                                                        };

 

My questions are 

1) is this a correct conversion? , Am I changing the behavior of the cache manager? 

2) There's an argument that the expirationCheckInterval which was passed to constructor of FileDependencyEx it was defining the intervals that system will check the file if that's correct what is the

frequency that a FileDepency is being checked now ? can I configure that at all ?

 

Any hints will help!

Thanks,

Robert B. 

Mar 19, 2010 at 7:58 AM

Hi,

I really haven't tried using caching in 1.1 version of ent lib, but based on the description that you've mentioned about the expirationCheckInterval, in the configuration of the cache manager, there is a property the you can set which is "ExpirationPollFrequencyInSeconds", its the interval where expirations are checked.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Mar 19, 2010 at 9:55 PM

Thanks Valiant.

I have never used file dependency before, which is a little confusing to me.

This is what I an concluding based on your answer:

1- Setting the cache expiration time for a File Dependency cache item means how often the dependency file is being checked for modifications which is not allowed in entLib 4.1.

However you can configure that by setting to value of "ExpirationPollFrequencyInSeconds" from Cache manager configuration file.

2- In case of sliding/absolute caching (not file dependency) what is the frequency of checking if the cache is expired ? or is it every time that cache item is being accessed?

3- In case of sliding/absolute caching (not file dependency) what's the meaning of "ExpirationPollFrequencyInSeconds"?

 

Thanks,

Robert B.

Mar 22, 2010 at 6:49 AM

Hi,

1- Setting the cache expiration time for a File Dependency cache item means how often the dependency file is being checked for modifications which is not allowed in entLib 4.1.

However you can configure that by setting to value of "ExpirationPollFrequencyInSeconds" from Cache manager configuration file.

Yes. It is allowed in 4.1 but not in the constructor of the FileDependency but rather in the config file. It is the ExpirationPollFrequencyInSeconds.

 

2- In case of sliding/absolute caching (not file dependency) what is the frequency of checking if the cache is expired ? or is it every time that cache item is being accessed?

It is still the ExpirationPollFrequencyInSeconds.

 

3- In case of sliding/absolute caching (not file dependency) what's the meaning of "ExpirationPollFrequencyInSeconds"?

Taken from the documentation:

expirationPollFrequencyInSeconds

Sets the timer that regulates how often the background scheduler checks for expired items. This attribute must be a positive integer. This attribute is required.

 

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Mar 22, 2010 at 7:59 PM
Edited Mar 22, 2010 at 8:00 PM

Excellent!

Thanks very much for clarifying this for me!

Robert