setExtra(key, extra)
Sets (replaces whole existing) extra in an item.
Arguments
key(string): Key to store the extra under (represents given item).extra(object): Extra data to replace existing one.
Throws
If
extrais not an object, it will throw'extra' must be an object.
Lifecycle
preSetExtra
Event name:
preSetExtraProperties passed:cacheInstancereference to cache instance (this)keykey passed tosetExtramethodextraextra passed tosetExtramethod
Returns: (object): object containing properties:
cacheInstancereference to cache instance (this)keykey passed through handlers added forpreSetExtraeventextraextra passed through handlers added forpreSetExtraevent
postSetExtra
Event name:
postSetExtraProperties passed:cacheInstancereference to cache instance (this) returned bypreSetExtrakeykey returned bypreSetExtraextraextra (object) returned by adapter using its setExtra method
Returns: (object): object containing properties:
cacheInstancereference to cache instance (this)keykey passed through handlers added forpostSetExtraeventextraextra passed through handlers added forpostSetExtraevent
Eventually
setExtrareturns extra returned bypostSetExtra.
Example
// Existing extra
{
some: 'data'
}
cache.setExtra(key, { foo: 'bar' });
// Extra after setting new one
{
foo: 'bar'
}Last updated