File tree Expand file tree Collapse file tree 3 files changed +38
-37
lines changed Expand file tree Collapse file tree 3 files changed +38
-37
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
# @labdigital/dataloader-cache-wrapper
2
2
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
+
3
40
## 0.2.0
4
41
5
42
### Minor Changes
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @labdigital/dataloader-cache-wrapper" ,
3
- "version" : " 0.2 .0" ,
3
+ "version" : " 0.3 .0" ,
4
4
"author" : " Lab Digital <opensource@labdigital.nl>" ,
5
5
"license" : " MIT" ,
6
6
"publishConfig" : {
You can’t perform that action at this time.
0 commit comments