addExtra(key, extra)
Adds extra to item's existing extra. New properties are added, existing are overwritten.
Arguments
key(string): Key to store the extra under (represents given item).extra(object): Extra data to store.
Throws
If
extrais not an object, it will throw'extra' must be an object.
Lifecycle
preAddExtra
Event name:
preAddExtraProperties passed:cacheInstancereference to cache instance (this)keykey passed toaddExtramethodextraextra passed toaddExtramethod
Returns: (object): object containing properties:
cacheInstancereference to cache instance (this)keykey passed through handlers added forpreAddExtraeventextraextra passed through handlers added forpreAddExtraevent
postAddExtra
Event name:
postAddExtraProperties passed:cacheInstancereference to cache instance (this) returned bypreAddExtrakeykey returned bypreAddExtraextraextra (object) returned by adapter using its addExtra method
Returns: (object): object containing properties:
cacheInstancereference to cache instance (this)keykey passed through handlers added forpostAddExtraeventextraextra passed through handlers added forpostAddExtraevent
Eventually
addExtrareturns extra returned bypostAddExtra.
Example
// Existing extra in an item
{
some: 'data'
}
cache.addExtra(key, { foo: 'bar' });
// Extra after adding new one
{
foo: 'bar',
some: 'data'
}
cache.addExtra(key, { foo: 'baz' });
// Extra after another round of adding stuff to it
{
foo: 'baz', // <-- notice that this value's changed
some: 'data'
}Last updated