0.3.0 • Published 13 days ago

@labdigital/dataloader-cache-wrapper v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
13 days ago

node-dataloader-cache-wrapper

Usage

import { dataloaderCache } from "@labdigital/dataloader-cache-wrapper"

export const createProductBySlugLoader = () => {
  return new DataLoader<ProductReference, any>(ProductDataLoader, {
    maxBatchSize: 50,
  });
};

export const ProductDataLoader = async (keys: readonly any[]): Promise<(Product | null)[]> => {
  return dataloaderCache(_uncachedProductDataLoader, keys, {
    store: new Keyv(),
    ttl: 3600,

    cacheKeysFn: (ref: ProductRef) => {
      const key = `${ref.store}-${ref.locale}-${ref.currency}`;
      return [`some-data:${key}:id:${ref.slug}`];
    },
  })
}
0.3.0

13 days ago

0.2.0

4 months ago

0.1.0

6 months ago

0.0.3

10 months ago

0.1.1

6 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.2

11 months ago

0.0.1

12 months ago