getItem(key)
Returns an item.
Arguments
key(string): Key to get an item by.
Lifecycle
preGetItem
Event name:
preGetItemProperties passed:cacheInstancereference to cache instance (this)keykey passed togetItemmethod
Returns: (object): object containing properties:
cacheInstancereference to cache instance (this)keykey passed through handlers added forpreGetItemevent
postGetItem
Event name:
postGetItemProperties passed:cacheInstancereference to cache instance (this) returned bypreGetItemkeykey returned bypreGetItemitemitem returned by adapter using its getItem method
Returns: (object): object containing properties:
cacheInstancereference to cache instance (this)keykey passed through handlers added forpostGetItemeventitemitem passed through handlers added forpostGetItemevent
Eventually
getItemreturns item returned bypostGetItem.
Returns
(Item): Item, an object.
(undefined): If item is not found, returns undefined.
Example
// assuming that you already have cache instance prepared
cache.getItem('key'); // Item
cache.getItem('keyForItemThatDoesNotExist'); // undefinedLast updated