-
Notifications
You must be signed in to change notification settings - Fork 2
Default Cache store
We need to provide RapidCache with an implementation of the ICacheStore
interface to use as a repository for our cache information. By default, it uses a Concurrent Dictionary in memory, it is easily declare using the default syntax for declaration:
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);
//The Memory Cache is declared implicitly here.
this.EnableRapidCache(
container.Resolve<IRouteResolver>(),
ApplicationPipelines);
}
}
}
Performance for the default cache varies depending on the timespan established on the cache. Since this could be determined per method definition, it is recommended that you test per each type of operation and response size.
The MemoryCacheStore allows to send an optional MaxSize value that will keep track of what is the max size of items allowed on the store, this is done in order to put a limit on the cap of memory usage the store can consume.
Note: The limit allows to remove evicted items when the limit is reached.