views:

42

answers:

2

Hi,

Is there a way to tell a CacheManager that every item added will have the same expiration policy?

For example in:

<cachingConfiguration defaultCacheManager="DefaultCacheManager">
    <cacheManagers>
        <add name="TestCM"
             expirationPollFrequencyInSeconds="60"
             maximumElementsInCacheBeforeScavenging="1000"
             numberToRemoveWhenScavenging="10"
             backingStoreName="Null Storage"
             type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

I expected to have some attribute like expirationPolicy="AbsoluteTime" or "SlidingTime" and a expirationValue="..." for specifying the timespan to use.

Thanks, s.

+1  A: 

I do not think that you can do this in the configuration.

What we normally do is to use a wrapper around the CacheManager, so there is only one place to set the expiration policy, you can then read the values from the application settings in the configuration file.

Shiraz Bhaiji
+1  A: 

Expiration is provided on the Add method to the Cache. Each item added to the cache can have their own expiration scheme and their own expiration time. Unfortunately, there is currently no way to specify a default scheme and time via the configuration. As Shiraz mentions, you should write a facade and specify the behavior you want in there.

Tuzo