createItem(key, value, [extra])

Creates an item.

Arguments

  1. key (string): key, under which given item will be stored. See buildKey (cacheInstance) and buildKey (adapter).

  2. value (any): value that is to be stored. See values.

  3. extra (object): extra data, optional. Will default to empty object if not passed {}. See item's structure for more info.

Throws

  1. If extra is not passed as an object, it will throw an error 'extra' must be an object.

Returns

(Item): Created item.

Example

import { createItem } from 'stash-it';

const item = createItem('key', 'value');

// OR

const itemWithPassedExtra = createItem('key', 'value', { some: 'additional stuff' });

Last updated