Extend DataBackingStore

Topics: Caching Application Block
Nov 23, 2010 at 5:11 PM

Hello, I am testing the Caching Application Block.

I am using DataBackingStore as backing store provider, and it basically does what I was looking for, but it lacks of a feature I am going to need.

I would like to override LoadDataFromStore(), I've decided to extend DataBackingStore. I am calling the new class: DataBackingStoreExtended.

To do that I've created a new element constructor for full integration, I have basically copied and pasted DataCacheStorageData, modifying the constructors to pass as parameter typeof(DataBackingStoreExtended). And the application compiles and run... but the instance it is being loaded is DataBackingStore instead of DataBackingStoreExtended.

This is what I've got in my app.config:

    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" />
    <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching"/>
  <dataConfiguration defaultDatabase="Connection String" />
    <add name="Connection String" connectionString="Database=Caching;Server=(local)\SQLEXPRESS;Integrated Security=SSPI"
        providerName="System.Data.SqlClient" />
  <cachingConfiguration defaultCacheManager="Cache Manager">
      <add name="Cache Manager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching"
          expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"
          numberToRemoveWhenScavenging="10" backingStoreName="ExtendedDatabaseCache" />

      <add name="ExtendedDatabaseCache" type="BackingStores.DataBackingStoreExtended, BackingStores"
        encryptionProviderName="" databaseInstanceName="Connection String"
        partitionName="MyApplication" />

Am I doing something wrong?
Nov 24, 2010 at 12:01 AM

Did you override the GetRegistrations method in your DataCacheStorageData?  You should override it and provide type registration/s which will enable entlib to create  your custom cache manager.


Sarah Urmeneta
Global Technologies & Solutions
Avanade, Inc.

Nov 24, 2010 at 8:33 AM

Hi Sarah,

It was the GetRegistrations method. I've changed it and now is working fine.

Thanks, and congrats for the library.

Jan 10, 2011 at 7:26 PM


Can you post your .GetRegistrations() method?

Jan 11, 2011 at 1:14 AM

If you're looking for a sample of an implementation of the GetRegistration method, you can check the entlib source code itself or refer to the Overriding the GetRegistrations Method section in this topic from the documentation.


Sarah Urmeneta
Global Technologies & Solutions
Avanade, Inc.