Caching extensions for creating and maintaining custom caches for Sitecore Development. Project is based on Helix Design Principles.
Clone or download
Kyle Kingsbury
Kyle Kingsbury Update
Latest commit 6f62dbf Dec 3, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Foundation/Caching Moves Readme to source control root Nov 28, 2016
.gitattributes Initial Commit Oct 31, 2016
.gitignore Initial Commit Oct 31, 2016
LICENSE.txt Initial Commit Oct 31, 2016
Sitecore.CacheExtensions.sln Moves Readme to source control root Nov 28, 2016
Sitecore.CacheExtensions.sln.DotSettings Initial Commit Oct 31, 2016 Update Dec 3, 2016


The Sitecore.CacheExtensions library is a series of extensions to provide configuration based caches, based on the helix design principles.


Using nuget: Install-Package Sitecore.CacheExtensions

Injected Services

The following classes are automatically injected into the Sitecore OTB Service Collection:

  • SitecoreCacheManager (ICacheManager) - Adds layer to expose configured caches
  • TransientCache (BaseTransientCache) - Adds caching per request within the HttpContext.Items
  • SessionCache (BaseSessionCache) - Adds caching per session within the HttpContext.Session

To grab a reference to either the SitecoreCacheManager, TransientCache, or SessionCache, add a class that extends the IServicesConfigurator and add your classes that you would like to be resolved.

public class RegisterDependencies : IServicesConfigurator 
        public void Configure(IServiceCollection serviceCollection)
            // Add your classes here using the serviceCollection methods
<?xml version="1.0"?>
<configuration xmlns:patch="">
      <configurator type="[Class], [Assembly Name]" />

For more information, see:

Adding a Sitecore Cache

Add a new cache by adding a path configuration like so:

<?xml version="1.0"?>
<configuration xmlns:patch="">
            <cache name="example-cache" maxSize="100MB" lifespan="60" expirationType="sliding" />

Configuring the Cache

All fields are required


Must be unique and is used to identify the cache with the Cache Manager


Max size of the cache in string representation


  • 100K
  • 10MB
  • 1GB


Lifetime of a cache entry, read in the number of seconds.


  • 60 = 1 minute
  • 360 = 6 minutes
  • 3600 = 1 hour


Determines how the cache entry should expire

Supported Expiration Types:

  • Sliding - expires entry if it hasn't been accessed within the lifespan
  • Absolute - expires entry after a set amount of time
  • Sticky (not implemented)