Custom Cache store - Jaxelr/Nancy.RapidCache GitHub Wiki

To implement a custom cache store all we need is to define an implementation for the ICacheStore interface:

    public interface ICacheStore
    {
        CachedResponse Get(string key);

        void Set(string key, NancyContext context, DateTime absoluteExpiration);

        void Remove(string key);
    }

There are a few pointers i recommend when caching:

  1. Check that the key is not empty (to avoid unnecesary lookups).
  2. Check that the object from the NancyContext you are going to store is not null (i.e. Response).
  3. Keep in mind that the absolute expiration parameter is defined as a utc date.