Extend DataBackingStore

Topics: Caching Application Block
Nov 23, 2010 at 4: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:

<configuration>
  <configSections>
    <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"/>
  </configSections>
  <dataConfiguration defaultDatabase="Connection String" />
  <connectionStrings>
    <add name="Connection String" connectionString="Database=Caching;Server=(local)\SQLEXPRESS;Integrated Security=SSPI"
        providerName="System.Data.SqlClient" />
  </connectionStrings>
  <cachingConfiguration defaultCacheManager="Cache Manager">
    <cacheManagers>
      <add name="Cache Manager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching"
          expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"
          numberToRemoveWhenScavenging="10" backingStoreName="ExtendedDatabaseCache" />
    </cacheManagers>
    <backingStores>

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

    </backingStores>
  </cachingConfiguration>
</configuration>
Am I doing something wrong?
Thanks
Nov 23, 2010 at 11:01 PM

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.
entlib.support@avanade.com

Nov 24, 2010 at 7: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 6:26 PM

road,


Can you post your .GetRegistrations() method?

Jan 11, 2011 at 12: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.
entlib.support@avanade.com