-
Notifications
You must be signed in to change notification settings - Fork 2
IMemory Cache Store
Jaxel Rojas edited this page Mar 1, 2020
·
4 revisions
RapidCache contains an implementation of an IMemoryCache as provided by the Microsoft.Abstraction.Caching.Memory library, in order to use it as part of your setup you must install it via nuget:
Install-Package Nancy.RapidCache.IMemoryAnd include it on your declaration of stores:
using Nancy.RapidCache.Extensions;
using Nancy.Routing;
using Nancy.TinyIoc;
using Nancy.Bootstrapper;
namespace MyCustomWebApp
{
public class ApplicationBootrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup
(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
//Declaring the Redis Cache Store explicitly.
this.EnableRapidCache(
container.Resolve<IRouteResolver>(),
ApplicationPipelines,
new[] { "query", "form", "accept" },
new IMemoryCacheStore());
}
}
}Alternatively, you can provide an object MemoryCacheOptions which could be used to allow for a limit size of objects allowed to be incorporated into the cache.
Check the official msdocs for flexible alternatives allowed on the declaration.