Hooks, when added, are stored in an object. Properties of that object are hook's events and values are arrays of handlers.
Examples
// assuming that you already have cache instance preparedconsthook1= { event:'preGetItem',handler: () => { ... } // some function that does something, not relevant here}consthook2= { event:'postSetItem',handler: () => { ... } // some function that does something, not relevant here}cache.addHooks([ hook1, hook2 ]);// In cache, hooks will be stored like so:{ hooks: { preGetItem: [ () => {} // handler from hook1 ], postSetItem: [ () => {} // handler from hook2 ] }}cache.getHooks(); // it will return object shown above
What will happen when I will add more hooks with same event names?
// continuing from the example aboveconsthook3= { event:'preGetItem',handler: () => {}}cache.addHook(hook3);//right now hooks will look like so:{ hooks: { preGetItem: [ () => {} // handler from hook1, () => {} // handler from hook3, added to the end of the list of hooks for given event ], postSetItem: [ () => {} // handler from hook2 ] }}