Adapter

First of all: what is an adapter?

Adapter is a bridge between cache instance and storage it uses.

For example: memory adapter provides access to memory, in which data is stored; mongo adapter will provide access to mongo DB, etc.

Adapter provides API for IO operations on given storage. APIs are, by design, all the same for all adapters.

Creating adapter instance

adapter(options)

Each adapter takes options (an object) as an argument. Depending on what adapter you use, you might have to pass different options.

All adapters have one required property (by design) that needs to be passed: namespace. Checkout namespaces docs to learn more about them.

import createMemoryAdapter from 'stash-it-adapter-memory';

const adapter = createMemoryAdapter({ namespace: 'someNamespace' });

Created adapter is an object with methods that provide access to storage given adapter uses.

results matching ""

    No results matching ""