hasItem(key)
Checks if item exists.
Arguments
key(string): Key to check if an item exists by.
Lifecycle
preHasItem
Event name:
preHasItemProperties passed:cacheInstancereference to cache instance (this)keykey passed tohasItemmethod
Returns: (object): object containing properties:
cacheInstancereference to cache instance (this)keykey passed through handlers added forpreHasItemevent
postHasItem
Event name:
postHasItemProperties passed:cacheInstancereference to cache instance (this) returned bypreHasItemkeykey returned bypreHasItemresultboolean value returned by adapter using its hasItem method
Returns: (object): object containing properties:
cacheInstancereference to cache instance (this)keykey passed through handlers added forpostHasItemeventresultboolean value passed through handlers added forpostHasItemevent
Eventually
hasItemreturns result returned bypostHasItem.
Even though hasItem uses buildKey internally, that build key is not passed in postHasItem event handler's object's properties. If key is somehow changed (with some plugin) during preBuildKey or postGetKey event handlers, that key is not passed further in hasItem. If you need access to built key, you can still obtain it from returned item to which you have access in postHasItem.
Returns
(bool): true if item exists, false otherwise.
Example
Last updated