Releases: labd/node-dataloader-cache-wrapper
Releases · labd/node-dataloader-cache-wrapper
v0.4.0
v0.3.0
Minor Changes
-
3fbea90: Move to
keyv
as cache implementation. This makes it compatible with various
cache implementations. To update replace theclient
option withstore
and
pass aKeyv
instance.
import { dataloaderCache } from "@labdigital/dataloader-cache-wrapper"
import Keyv from 'keyv';
const redis = new Redis('redis://user:pass@localhost:6379');
const keyvRedis = new KeyvRedis(redis);
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({ store: keyvRedis }),
ttl: 3600,
cacheKeysFn: (ref: ProductRef) => {
const key = `${ref.store}-${ref.locale}-${ref.currency}`;
return [`some-data:${key}:id:${ref.slug}`];
},
})
}
## 0.2.0
### Minor Changes
- ffe9f26: Refactor to simplify the API by removing the lookupFn callback
## 0.1.1
### Patch Changes
- 0fd4457: Fix silly typo in latest change. bachLoadFn -> batchLoadFn
## 0.1.0
### Minor Changes
- 01243d5: Move all arguments to the options object for consistency
- dc082bf: Add support for adding a callback to prime the dataloader cache
## 0.0.5
### Patch Changes
- 822774e: Simplify the lookupFn function definition to improve the API
## 0.0.4
### Patch Changes
- 0edf554: Fix release artifact
## 0.0.3
### Patch Changes
- bedf41c: Fix ESM exports
## 0.0.2
### Patch Changes
- 95be409: Fix issue returning missing items from the dataloader