Skip to content

Commit 914bb2d

Browse files
committed
chore: changeset releases
1 parent 92139b1 commit 914bb2d

6 files changed

+78
-85
lines changed

.changeset/curvy-poets-attack.md

-32
This file was deleted.

.changeset/eleven-hats-retire.md

-5
This file was deleted.

.changeset/kind-forks-repeat.md

-10
This file was deleted.

.changeset/thick-tomatoes-watch.md

-37
This file was deleted.

packages/bentocache/CHANGELOG.md

+77
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,82 @@
11
# bentocache
22

3+
## 1.1.0
4+
5+
### Minor Changes
6+
7+
- 07224ba: Add two new functions in the factory callback context:
8+
9+
```ts
10+
cache.getOrSet({
11+
key: 'foo',
12+
factory: ({ skip, fail }) => {
13+
const item = await getFromDb()
14+
if (!item) {
15+
return skip()
16+
}
17+
18+
if (item.isInvalid) {
19+
return fail('Item is invalid')
20+
}
21+
22+
return item
23+
},
24+
})
25+
```
26+
27+
## Skip
28+
29+
Returning `skip` in a factory will not cache the value, and `getOrSet` will returns `undefined` even if there is a stale item in cache.
30+
It will force the key to be recalculated on the next call.
31+
32+
## Fail
33+
34+
Returning `fail` in a factory will not cache the value and will throw an error. If there is a stale item in cache, it will be used.
35+
36+
- 2578357: Added a `serialize: false` to the memory driver.
37+
38+
It means that, the data stored in the memory cache will not be serialized/parsed using `JSON.stringify` and `JSON.parse`. This allows for a much faster throughput but at the expense of:
39+
40+
- not being able to limit the size of the stored data, because we can't really know the size of an unserialized object
41+
- Having inconsistent return between the L1 and L2 cache. The data stored in the L2 Cache will always be serialized because it passes over the network. Therefore, depending on whether the data is retrieved from the L1 and L2, we can have data that does not have the same form. For example, a Date instance will become a string if retrieved from the L2, but will remain a Date instance if retrieved from the L1. So, you should put extra care when using this feature with an additional L2 cache.
42+
43+
### Patch Changes
44+
45+
- 09cd234: Refactoring of CacheEntryOptions class. We switch to a simple function that returns an object rather than a class. Given that CacheEntryOptions is heavily used : it was instantiated for every cache operation, we gain a lot in performance.
46+
- 1939ab9: Deleted the getters usage in the CacheEntryOptions file. Looks like getters are super slow. Just removing them doubled the performance in some cases.
47+
48+
Before :
49+
50+
```sh
51+
┌─────────┬──────────────────────────────────┬─────────────────────┬─────────────────────┬────────────────────────┬────────────────────────┬─────────┐
52+
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
53+
├─────────┼──────────────────────────────────┼─────────────────────┼─────────────────────┼────────────────────────┼────────────────────────┼─────────┤
54+
│ 0 │ 'L1 GetOrSet - BentoCache''16613 ± 97.87%''1560.0 ± 45.00''613098 ± 0.10%''641026 ± 19040' │ 83796 │
55+
│ 1 │ 'L1 GetOrSet - CacheManager''953451 ± 111.03%''160022 ± 3815.00''5700 ± 1.23%''6249 ± 151' │ 1049 │
56+
│ 4 │ 'Tiered GetOrSet - BentoCache''16105 ± 98.11%''1515.0 ± 45.00''636621 ± 0.08%''660066 ± 20206' │ 86675 │
57+
│ 5 │ 'Tiered GetOrSet - CacheManager''877297 ± 111.36%''161617 ± 2876.00''5948 ± 0.67%''6187 ± 112' │ 1140 │
58+
│ 6 │ 'Tiered Get - BentoCache''1542.4 ± 4.43%''992.00 ± 18.00''973931 ± 0.03%''1008065 ± 17966' │ 648343 │
59+
│ 7 │ 'Tiered Get - CacheManager''1957.6 ± 0.51%''1848.0 ± 26.00''534458 ± 0.02%''541126 ± 7722' │ 510827 │
60+
└─────────┴──────────────────────────────────┴─────────────────────┴─────────────────────┴────────────────────────┴────────────────────────┴─────────┘
61+
```
62+
63+
After:
64+
65+
```sh
66+
┌─────────┬──────────────────────────────────┬─────────────────────┬─────────────────────┬────────────────────────┬────────────────────────┬─────────┐
67+
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
68+
├─────────┼──────────────────────────────────┼─────────────────────┼─────────────────────┼────────────────────────┼────────────────────────┼─────────┤
69+
│ 0 │ 'L1 GetOrSet - BentoCache''9610.3 ± 98.26%''1109.0 ± 29.00''879036 ± 0.05%''901713 ± 22979' │ 143980 │
70+
│ 1 │ 'L1 GetOrSet - CacheManager''906687 ± 110.96%''172470 ± 1785.00''5601 ± 0.56%''5798 ± 61' │ 1103 │
71+
│ 4 │ 'Tiered GetOrSet - BentoCache''8752.8 ± 98.40%''1060.0 ± 19.00''924367 ± 0.04%''943396 ± 17219' │ 158461 │
72+
│ 5 │ 'Tiered GetOrSet - CacheManager''925163 ± 111.45%''173578 ± 2970.00''5590 ± 0.55%''5761 ± 100' │ 1081 │
73+
│ 6 │ 'Tiered Get - BentoCache''556.57 ± 0.52%''511.00 ± 10.00''1923598 ± 0.01%''1956947 ± 37561' │ 1796720 │
74+
│ 7 │ 'Tiered Get - CacheManager''2060.2 ± 2.54%''1928.0 ± 20.00''513068 ± 0.02%''518672 ± 5325' │ 485387 │
75+
└─────────┴──────────────────────────────────┴─────────────────────┴─────────────────────┴────────────────────────┴────────────────────────┴─────────┘
76+
```
77+
78+
Pretty good improvement 😁
79+
380
## 1.0.0
481

582
- eeb3c8c: BREAKING CHANGES:

packages/bentocache/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bentocache",
33
"type": "module",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"description": "Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers",
66
"author": "Julien Ripouteau <[email protected]>",
77
"license": "MIT",

0 commit comments

Comments
 (0)