Skip to content

Commit ac4797e

Browse files
asvishnyakovwodCZ
authored andcommitted
fix: persist cache on garbage collection
1 parent 2a9e3e9 commit ac4797e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/onCacheWrite.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default <T>({ cache }: TriggerFunctionConfig<T>) => (
1010
const write = cache.write;
1111
const evict = cache.evict;
1212
const modify = cache.modify;
13+
const gc = cache.gc;
1314

1415
cache.write = (...args: any[]) => {
1516
const result = write.apply(cache, args);
@@ -26,10 +27,17 @@ export default <T>({ cache }: TriggerFunctionConfig<T>) => (
2627
persist();
2728
return result;
2829
};
30+
cache.gc = (...args: any[]) => {
31+
const result = gc.apply(cache, args);
32+
persist();
33+
return result;
34+
};
35+
2936

3037
return () => {
3138
cache.write = write;
3239
cache.evict = evict;
3340
cache.modify = modify;
41+
cache.gc = gc;
3442
};
3543
};

0 commit comments

Comments
 (0)