Cache In On the Enterprise Library Caching Block for .NET 2.0 : Page 2
Nearly every application needs to cache data. While you're probably familiar wth the caching functionality built into ASP.NET, the Enterprise Library Caching Block provides in-memory, file-based, or database caching storage for all your other .NET applications.
by Thiru Thangarathinam
Apr 6, 2006
Page 2 of 4
Using the Caching Application Block
After installing the Enterprise Library, you still need to perform some setup steps to use the Caching Block successfully in a project. Follow the steps listed below:
Add a reference to the Microsoft.Practices.EnterpriseLibrary.Common.dll and Microsoft.Practices.EnterpriseLibrary.Caching.dll assemblies to your solution using the "Add Reference" option and navigating to the <Drive Name>:\Program Files\Microsoft Enterprise Library January 2006\bin folder on the drive where you installed the Enterprise Library. If you decide to use the database as a caching store, you also need to add a reference to the Data Access Block (the Microsoft.Practices.EnterpriseLibrary.Caching.Data.dll).
Add the necessary configuration entries to the app.config or web.config file. To this end, you add the <configSections> element under the root <configuration> element.
The preceding settings show how to configure the cache to use an in-memory store by default. While you can add the settings manually, it's far easier to add them using the Enterprise Library Configuration Tool that ships with Enterprise Library. When viewed through the Enterprise Library Configuration tool the preceding settings look like Figure 1.
Add an "Imports" (or using, in C#) line for the core namespace for the Caching Block, "Microsoft.Practices.EnterpriseLibrary.Caching" to your code.
Now you're ready to begin writing code that takes advantage of the Caching Block.