vapor-chamber API reference - v1.3.0
    Preparing search index...

    Function cache

    • cache — memoize handler results by (action, target) key. Use with query() for read-only commands. The plugin intercepts the dispatch/query pipeline and returns the cached result if fresh.

      Parameters

      Returns Plugin & {
          invalidate(action: string, target?: any): void;
          clear(): void;
          size(): number;
      }

      • invalidate: function
        • Manually invalidate a cache entry.

          Parameters

          • action: string
          • Optionaltarget: any

          Returns void

      • clear: function
      • size: function
      bus.use(cache({ ttl: 60_000, actions: ['getUser*'] }));
      bus.query('getUser', { id: 42 }); // handler runs
      bus.query('getUser', { id: 42 }); // cache hit, handler skipped