setItem(key, value, [extra])

This method sets an item and returns it as well.

Arguments

  1. key (string): A string used to store an item under.

  2. value (any): Any value that can be stored in cache. Depends on adapter you use (and storage this adapter grants access to). See values for more info.

  3. extra (object): It's optional. It allows you to pass additional (extra) data that you want to store alongside value. See how that can be used in lifecycle methods and plugins.

Returns

(Item): Built item, an object.

Example

// without extra
const item1 = adapter.setItem('key1', 'some value to store');

// with extra
const item2 = adapter.setItem('key2', 'some other value', { extra: 'information to store' });

Last updated