removeItem(key)

Removes an item.

Arguments

  1. key (string): Key to remove an item by.

Lifecycle

  1. preRemoveItem

    Event name: preRemoveItem Properties passed:

    • cacheInstance reference to cache instance (this)

    • key key passed to removeItem method

    Returns: (object): object containing properties:

    • cacheInstance reference to cache instance (this)

    • key key passed through handlers added for preRemoveItem event

  2. postRemoveItem

    Event name: postRemoveItem Properties passed:

    • cacheInstance reference to cache instance (this) returned by preRemoveItem

    • key key returned by preRemoveItem

    • result boolean value returned by adapter using its removeItem method

    Returns: (object): object containing properties:

    • cacheInstance reference to cache instance (this)

    • key key passed through handlers added for postRemoveItem event

    • result boolean value passed through handlers added for postRemoveItem event

    Eventually removeItem returns result returned by postRemoveItem.

Returns

(bool): true if item was removed, false otherwise.

Example

// assuming that you already have cache instance prepared
cache.removeItem('key'); // true
cache.removeItem('keyForItemThatDoesNotExist'); // false

Last updated