|
| 1 | +# bentocache |
| 2 | + |
| 3 | +## 1.0.0 |
| 4 | + |
| 5 | +- eeb3c8c: BREAKING CHANGES: |
| 6 | + This commit changes the API of the `gracePeriod` option. |
| 7 | + - `gracePeriod` is now `grace` and should be either `false` or a `Duration`. |
| 8 | + - If you were using the `fallbackDuration` option, you should now use the `graceBackoff` option at the root level. |
| 9 | +- 82e9d6c: Previously, `suppressL2Errors` was automatically enabled even when we had just a L2 layer. Which can be confusing, because errors were filtered out. |
| 10 | + |
| 11 | + Now `suppressL2Errors` is a bit more intelligent and will only be enabled if you have a L1 layer. Unless you explicitly set it to `true`. |
| 12 | + |
| 13 | +- 716a423: BREAKING CHANGES : |
| 14 | + |
| 15 | + `undefined` values are forbidden in the cache. If you are trying to cache `undefined`, you will now get an error. This is a breaking change because it was previously allowed. |
| 16 | + |
| 17 | + If you want to cache something to represent the absence of a value, you can use `null` instead of `undefined`. |
| 18 | + |
| 19 | +- 4478db6: BREAKING CHANGES |
| 20 | + |
| 21 | + ## API Changes for timeouts |
| 22 | + |
| 23 | + The timeout options have changed APIs: |
| 24 | + `{ soft: '200ms', hard: '2s' }` |
| 25 | + |
| 26 | + Becomes: |
| 27 | + |
| 28 | + ```ts |
| 29 | + getOrSet({ timeout: '200ms', hardTimeout: '2s' }) |
| 30 | + ``` |
| 31 | + |
| 32 | + You can now also use `0` for `timeout` which means that, if a stale value is available, then it will be returned immediately, and the factory will run in the background. SWR-like, in short. |
| 33 | + |
| 34 | + ## Default timeout |
| 35 | + |
| 36 | + Now, the default timeout is `0`. As explained above, this enables the SWR-like behavior by default, which is a good default for most cases and what most people expect. |
| 37 | + |
| 38 | +- 7ae55e2: Added an `onFactoryError` option that allows to catch errors that happen in factories, whether they are executed in background or not. |
| 39 | + |
| 40 | + ```ts |
| 41 | + const result = await cache.getOrSet({ |
| 42 | + key: 'foo', |
| 43 | + grace: '5s', |
| 44 | + factory: () => { |
| 45 | + throw new MyError() |
| 46 | + }, |
| 47 | + onFactoryError: (error) => { |
| 48 | + // error is an instance of errors.E_FACTORY_ERROR |
| 49 | + // error.cause is the original error thrown by the factory |
| 50 | + // you can also check if the factory was executed in background with error.isBackgroundFactory |
| 51 | + // and also get the key with error.key. Will be `foo` in this case |
| 52 | + }, |
| 53 | + }) |
| 54 | + ``` |
| 55 | + |
| 56 | +- 27a295d: Keep only POJO syntax |
| 57 | + |
| 58 | + This commit remove the "legacy" syntax and only keep the POJO syntax. |
| 59 | + For each method, the method signature is a full object, for example : |
| 60 | + |
| 61 | + ```ts |
| 62 | + bento.get({ key: 'foo ' }) |
| 63 | + bento.getOrSet({ |
| 64 | + key: 'foo', |
| 65 | + factory: () => getFromDb(), |
| 66 | + }) |
| 67 | + ``` |
| 68 | + |
| 69 | +- f0b1008: The memory driver can now accept `maxSize` and `maxEntrySize` in human format. For example, `maxSize: '1GB'` or `maxEntrySize: '1MB'`. |
| 70 | + |
| 71 | + We use https://www.npmjs.com/package/bytes for parsing so make sure to respect the format accepted by this module. |
| 72 | + |
| 73 | +- a8ac574: This commit adds a new custom behavior for handling GetSet operation when end-user is using a single L2 storage without L1 cache. |
0 commit comments