expirationPollFrequencyInSeconds does nothing

Topics: Caching Application Block
Jan 6, 2010 at 8:42 AM

Hi all,

I use EnterpriseLibrary Caching.

There is following configuration in web.config

  <cachingConfiguration defaultCacheManager="SessionCache">
    <backingStores>
      <add name="inMemory"
type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching" />
    </backingStores>
    <cacheManagers>
      <add name="SessionCache"
type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching"
           expirationPollFrequencyInSeconds="60"
           maximumElementsInCacheBeforeScavenging="1000"
           numberToRemoveWhenScavenging="10"
           backingStoreName="inMemory" />
    </cacheManagers>
  </cachingConfiguration>

I wrote several tests to test how expirationPollFrequencyInSecondsmaximumElementsInCacheBeforeScavenging and numberToRemoveWhenScavenging work.

expirationPollFrequencyInSeconds did not influence on anything. None item is deleted after defined 60 seconds. 

Did someone tried to check if this property effect anything? 

I expect deleting of CacheItems that are in cache more then 60 seconds. 

  <cachingConfiguration expirationPollFrequencyInSeconds defaultCacheManager="SessionCache">
    <backingStores>
      <add name="inMemory"
           type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching" />
    </backingStores>
    <cacheManagers>
      <add name="SessionCache"
            type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching"
            expirationPollFrequencyInSeconds="1"
            maximumElementsInCacheBeforeScavenging="5"
            numberToRemoveWhenScavenging="2"
            backingStoreName="inMemory" />
      <add name="ProviderCache"
           type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching"
           expirationPollFrequencyInSeconds="60"
           maximumElementsInCacheBeforeScavenging="1000"
           numberToRemoveWhenScavenging="10"
           backingStoreName="inMemory" />
      <add name="TransactionModuleDiagnosticCache"
           type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching"
           expirationPollFrequencyInSeconds="60"
           maximumElementsInCacheBeforeScavenging="1000"
           numberToRemoveWhenScavenging="10"
           backingStoreName="inMemory" />
      <add name="ExternalGameCache"
           type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching"
           expirationPollFrequencyInSeconds="60"
           maximumElementsInCacheBeforeScavenging="1000"
           numberToRemoveWhenScavenging="10"
           backingStoreName="inMemory" />
    </cacheManagers>
  </cachingConfiguration
Jan 6, 2010 at 8:47 AM

Well, did you have more than 1000 items in your cache after 60 seconds? 

 

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

Jan 6, 2010 at 8:52 AM

Just after I add 1001 item to cache 10 first items are deleted.

So I can not exceed number of cache items 1000.

Jan 6, 2010 at 9:05 AM

I asked the wrong question, sorry.  Let me just explain that the polling that will happen in 60 seconds actually checks if there are items in the cache that are already expired.  So if you want to see the effect, Add items in the cache less than 1000, say 50, configure a cache item to expire in 60 seconds.  After 60 seconds, the number of items in the cache should be 49.

 

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

Jan 6, 2010 at 9:13 AM

It works!

Thank you!