Skip to content

Commit f83e8e3

Browse files
github-actions[bot]mvantellingen
authored andcommitted
update version
1 parent d1b56c7 commit f83e8e3

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed

.changeset/clean-bulldogs-cheat.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# @labdigital/dataloader-cache-wrapper
22

3+
## 0.3.0
4+
5+
### Minor Changes
6+
7+
- 3fbea90: Move to `keyv` as cache implementation. This makes it compatible with various
8+
cache implementations. To update replace the `client` option with `store` and
9+
pass a `Keyv` instance.
10+
11+
```ts
12+
13+
14+
import { dataloaderCache } from "@labdigital/dataloader-cache-wrapper"
15+
import Keyv from 'keyv';
16+
17+
const redis = new Redis('redis://user:pass@localhost:6379');
18+
const keyvRedis = new KeyvRedis(redis);
19+
20+
export const createProductBySlugLoader = () => {
21+
return new DataLoader<ProductReference, any>(ProductDataLoader, {
22+
maxBatchSize: 50,
23+
});
24+
};
25+
26+
export const ProductDataLoader = async
27+
(keys: readonly any[]): Promise<(Product | null)[]> => {
28+
return dataloaderCache(_uncachedProductDataLoader, keys, {
29+
store: new Keyv({ store: keyvRedis }),
30+
ttl: 3600,
31+
32+
cacheKeysFn: (ref: ProductRef) => {
33+
const key = `${ref.store}-${ref.locale}-${ref.currency}`;
34+
return [`some-data:${key}:id:${ref.slug}`];
35+
},
36+
})
37+
}
38+
```
39+
340
## 0.2.0
441

542
### Minor Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labdigital/dataloader-cache-wrapper",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"author": "Lab Digital <opensource@labdigital.nl>",
55
"license": "MIT",
66
"publishConfig": {

0 commit comments

Comments
 (0)