Using Caching block without configuration

Topics: Building and extending application blocks, Caching Application Block
Jul 25, 2008 at 10:42 PM

We want to use Caching Application Block to reduce the memory foot print of the application by caching frequently used items using CAB. I would like to know what are the assemblies at minimum are required for using Caching Application Block. It seems like we can avoid having the configuration also. Can anybody help me understand how we can use Caching Application Block with any configuration file and also what are the assemblies required at minimum.

Also I would like to use the SQL CE as Backing Store for my caching implementation, any thoughts in that direction also would be great.

Jul 29, 2008 at 1:49 AM

You can use most blocks without a configuration file in two ways:

  • By creating new instances of the runtime objects, supplying the appropriate parameters in the constructors. For the CacheManager object the creation process is more involved and requires wiring up several objects; you can use the CacheManagerFactoryHelper class to do most of the heavy lifting for you.
  • Set up an DictionaryConfigurationSource with the graph of configuration elements that would have been deserialized from the configuration file and feed it to a factory. You can see how this is done in the PersistentCacheFeatureFixture test class.

You typically need to deploy the ObjectBuilder2 assembly, the Core assembly and the block assembly (Caching in this case), plus the assemblies for non-core providers together with the assemblies for the blocks used by the providers (Caching.Database and Database, if you use a database as the backing store).

About how to use SqlCE as a backing store, I don't know if it supports the features used by the DataBackingStore. You can set up a connection string for a SqlCE database and a DataBackingStore for that connection string and start from there.

Hope this gets you started,

Jul 29, 2008 at 7:47 PM

I took a look at the DataBackingStore and it uses stored procedures, so you will not be able to use it with SqlCE. You could try to create your own backing store that uses straight SQL instead of stored procedures and use it with SqlCE.