Programmatically caching things in Sitecore

I’ve seen a number of Sitecore projects now that use the ASP.NET cache, and this bothers me slightly. Shouldn’t Sitecore – which does have it’s own caching – offer a way of caching itself? Perhaps with integration to things like ‘clear cache on publish’, etc.?

Well, it does, and Anders Laub describes it neatly in “How to create a custom cache in Sitecore“. 

The TL;DR version is:

  • Create a subclass of CustomCache
  • Implement a Constructor that calls the Base constructor with a name and maximum size.
  • Create a cache object that implements ICacheable
  • Wrap access to the cache in a Static class with Get() and Set() methods

It’s a good post that one, well worth reading.

Advertisement
Programmatically caching things in Sitecore

One thought on “Programmatically caching things in Sitecore

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.