-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b96743
commit b7d2137
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |