Search code examples
.netcachingenterprise-library

Can expiration policies be configured in entlib caching application block?


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.


Solution

  • 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.