Contribute to Docs Contribute to Docs

Distributed Cache

The Distributed Cache is dependent on the standard IDistributedCache. The distributed cache is included in the core Piranha package meaning that no additional packages needs to be installed.

Please note that for the cache to work you will need to have a cache service registered in your application that implement IDistributedCache as well, for example RedisCache.

Register The Service

To register the distributed cache, simply add the following call to your Startup.cs.

using Piranha;

public void ConfigureServices(IServiceCollection services)
{
    ...

    services.AddPiranhaDistributedCache();

    ...
}

This will register the cache as a Singleton and it will be injected into all services. Please note that to actually use the cache in the repositories you need to set the current Cache Level of your application. For more information see Caching.