diff --git a/src/onCacheWrite.ts b/src/onCacheWrite.ts index dd67d7bf..c6817adf 100644 --- a/src/onCacheWrite.ts +++ b/src/onCacheWrite.ts @@ -8,13 +8,28 @@ export default ({ cache }: TriggerFunctionConfig) => ( persist: () => void, ) => { const write = cache.write; + const evict = cache.evict; + const modify = cache.modify; + cache.write = (...args: any[]) => { - const ref = write.apply(cache, args); + const result = write.apply(cache, args); + persist(); + return result; + }; + cache.evict = (...args: any[]) => { + const result = evict.apply(cache, args); + persist(); + return result; + }; + cache.modify = (...args: any[]) => { + const result = modify.apply(cache, args); persist(); - return ref; + return result; }; return () => { cache.write = write; + cache.evict = evict; + cache.modify = modify; }; };