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}`];
},
})
}
-
Notifications
You must be signed in to change notification settings - Fork 1
License
labd/node-dataloader-cache-wrapper
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published