cachified icon indicating copy to clipboard operation
cachified copied to clipboard

Performance: support batch-operations on caches

Open Xiphe opened this issue 1 year ago • 0 comments

When working with batches, some caches could support batch get/set/delete operations. It would probably save bandwidth / time when cachified would support these operations and fall back to parallel single operations when not supported by the cache.

export interface Cache {
    name?: string;
    get: (key: string) => Eventually<CacheEntry<unknown>>;
    set: (key: string, value: CacheEntry<unknown>) => unknown | Promise<unknown>;
    delete: (key: string) => unknown | Promise<unknown>;
    batch?: {
      get: (keys: string[]) => Eventually<CacheEntry<unknown>[]>;
      set: (entries: { key: string, value: CacheEntry<unknown> }[]) => unknown | Promise<unknown>;
      delete: (keys: string[]) => unknown | Promise<unknown>;
    }
}

Xiphe avatar Nov 07 '22 11:11 Xiphe