hasItem(key)

Checks if item exists.

Arguments

  1. key (string): Key to check if an item exists by.

Lifecycle

  1. preHasItem

    Event name: preHasItem Properties passed:

    • cacheInstance reference to cache instance (this)

    • key key passed to hasItem method

    Returns: (object): object containing properties:

    • cacheInstance reference to cache instance (this)

    • key key passed through handlers added for preHasItem event

  2. postHasItem

    Event name: postHasItem Properties passed:

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

    • key key returned by preHasItem

    • result boolean value returned by adapter using its hasItem method

    Returns: (object): object containing properties:

    • cacheInstance reference to cache instance (this)

    • key key passed through handlers added for postHasItem event

    • result boolean value passed through handlers added for postHasItem event

    Eventually hasItem returns result returned by postHasItem.

Returns

(bool): true if item exists, false otherwise.

Example

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

Last updated