createCache(adapter)

Creates a cache instance.

Arguments

  1. adapter (Adapter): Adapter's instance, any compatible with stash-it. See list of available adapters.

Throws

  1. If adapter is not an object, it will throw an error 'adapter' must be an object.

  2. If adapter does not contain all required methods, it will throw an error Not all required methods are present in adapter.

  3. If not all of the methods are functions, it will throw an error Not all required methods are functions.

Returns

(cacheInstance): Created cache instance.

Example

import { createCache } from 'stash-it';
import createAdapter from 'any-stash-it-compatible-adapter'; // e.g. stash-it-adapter-memory

const adapter = createAdapter();
const cacheInstance = createCache(adapter);

Last updated