diff --git a/.changeset/hip-cameras-kneel.md b/.changeset/hip-cameras-kneel.md new file mode 100644 index 0000000..c04bee6 --- /dev/null +++ b/.changeset/hip-cameras-kneel.md @@ -0,0 +1,28 @@ +--- +'bentocache': minor +--- + +Enhance Factory Context by adding some new props. + +```ts +await cache.getOrSet({ + key: 'foo', + factory: (ctx) => { + // You can access the graced entry, if any, from the context + if (ctx.gracedEntry?.value === 'bar') { + return 'foo' + } + + // You should now use `setOptions` to update cache entry options + ctx.setOptions({ + tags: ['foo'], + ttl: '2s', + skipL2Write: true, + }) + + return 'foo'; + } +}) +``` + +`setTtl` has been deprecated in favor of `setOptions` and will be removed in the next major version. diff --git a/.changeset/stupid-moose-care.md b/.changeset/stupid-moose-care.md new file mode 100644 index 0000000..ddf4fc7 --- /dev/null +++ b/.changeset/stupid-moose-care.md @@ -0,0 +1,16 @@ +--- +'bentocache': minor +--- + +Add `skipL2Write` and `skipBusNotify` options. + +```ts +await cache.getOrSet({ + key: 'foo', + skipL2Write: true, + skipBusNotify: true, + factory: () => 'foo' +}) +``` + +When enabled, `skipL2Write` will prevent the entry from being written to L2 cache, and `skipBusNotify` will prevent any notification from being sent to the bus. You will probably never need to use these options, but they were useful for internal code, so decided to expose them.