cacheable 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > High Performance Layer 1 / Layer 2 Caching with Keyv Storage
4
4
 
5
- [![codecov](https://codecov.io/gh/jaredwray/cacheable/graph/badge.svg?token=lWZ9OBQ7GM)](https://codecov.io/gh/jaredwray/cacheable)
5
+ [![codecov](https://codecov.io/gh/jaredwray/cacheable/branch/main/graph/badge.svg?token=lWZ9OBQ7GM)](https://codecov.io/gh/jaredwray/cacheable)
6
6
  [![tests](https://github.com/jaredwray/cacheable/actions/workflows/tests.yml/badge.svg)](https://github.com/jaredwray/cacheable/actions/workflows/tests.yml)
7
7
  [![npm](https://img.shields.io/npm/dm/cacheable.svg)](https://www.npmjs.com/package/cacheable)
8
8
  [![npm](https://img.shields.io/npm/v/cacheable)](https://www.npmjs.com/package/cacheable)
@@ -793,9 +793,12 @@ export type GetOrSetFunctionOptions = {
793
793
  ttl?: number | string;
794
794
  cacheErrors?: boolean;
795
795
  throwErrors?: boolean;
796
+ nonBlocking?: boolean;
796
797
  };
797
798
  ```
798
799
 
800
+ The `nonBlocking` option allows you to override the instance-level `nonBlocking` setting for the `get` call within `getOrSet`. When set to `false`, the `get` will block and wait for a response from the secondary store before deciding whether to call the provided function. When set to `true`, the primary store returns immediately and syncs from secondary in the background.
801
+
799
802
  Here is an example of how to use the `getOrSet` method:
800
803
 
801
804
  ```javascript
package/dist/index.cjs CHANGED
@@ -899,8 +899,9 @@ var Cacheable = class extends import_hookified2.Hookified {
899
899
  * @return {Promise<T | undefined>} - A promise that resolves to the cached or newly computed value, or undefined if an error occurs and caching is not configured for errors.
900
900
  */
901
901
  async getOrSet(key, function_, options) {
902
+ const getOptions = options?.nonBlocking === void 0 ? void 0 : { nonBlocking: options.nonBlocking };
902
903
  const cacheAdapter = {
903
- get: async (key2) => this.get(key2),
904
+ get: async (key2) => this.get(key2, getOptions),
904
905
  /* v8 ignore next -- @preserve */
905
906
  has: async (key2) => this.has(key2),
906
907
  set: async (key2, value, ttl) => {
@@ -917,7 +918,8 @@ var Cacheable = class extends import_hookified2.Hookified {
917
918
  cacheId: this._cacheId,
918
919
  ttl: options?.ttl ?? this._ttl,
919
920
  cacheErrors: options?.cacheErrors,
920
- throwErrors: options?.throwErrors
921
+ throwErrors: options?.throwErrors,
922
+ nonBlocking: options?.nonBlocking
921
923
  };
922
924
  return (0, import_utils.getOrSet)(key, function_, getOrSetOptions);
923
925
  }
package/dist/index.js CHANGED
@@ -884,8 +884,9 @@ var Cacheable = class extends Hookified2 {
884
884
  * @return {Promise<T | undefined>} - A promise that resolves to the cached or newly computed value, or undefined if an error occurs and caching is not configured for errors.
885
885
  */
886
886
  async getOrSet(key, function_, options) {
887
+ const getOptions = options?.nonBlocking === void 0 ? void 0 : { nonBlocking: options.nonBlocking };
887
888
  const cacheAdapter = {
888
- get: async (key2) => this.get(key2),
889
+ get: async (key2) => this.get(key2, getOptions),
889
890
  /* v8 ignore next -- @preserve */
890
891
  has: async (key2) => this.has(key2),
891
892
  set: async (key2, value, ttl) => {
@@ -902,7 +903,8 @@ var Cacheable = class extends Hookified2 {
902
903
  cacheId: this._cacheId,
903
904
  ttl: options?.ttl ?? this._ttl,
904
905
  cacheErrors: options?.cacheErrors,
905
- throwErrors: options?.throwErrors
906
+ throwErrors: options?.throwErrors,
907
+ nonBlocking: options?.nonBlocking
906
908
  };
907
909
  return getOrSet(key, function_, getOrSetOptions);
908
910
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacheable",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "High Performance Layer 1 / Layer 2 Caching with Keyv Storage",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -27,25 +27,22 @@
27
27
  "license": "MIT",
28
28
  "private": false,
29
29
  "devDependencies": {
30
- "@biomejs/biome": "^2.3.8",
31
- "@faker-js/faker": "^10.1.0",
30
+ "@faker-js/faker": "^10.2.0",
32
31
  "@keyv/redis": "^5.1.5",
33
32
  "@keyv/valkey": "^1.0.11",
34
- "@qified/redis": "^0.5.3",
35
- "@types/node": "^25.0.2",
36
- "@vitest/coverage-v8": "^4.0.15",
33
+ "@qified/redis": "^0.6.0",
34
+ "@types/node": "^24.10.10",
37
35
  "lru-cache": "^11.2.4",
38
36
  "rimraf": "^6.1.2",
39
37
  "tsup": "^8.5.1",
40
- "typescript": "^5.9.3",
41
- "vitest": "^4.0.15"
38
+ "typescript": "^5.9.3"
42
39
  },
43
40
  "dependencies": {
44
- "hookified": "^1.14.0",
45
- "keyv": "^5.5.5",
46
- "qified": "^0.5.3",
47
- "@cacheable/memory": "^2.0.6",
48
- "@cacheable/utils": "^2.3.2"
41
+ "hookified": "^1.15.0",
42
+ "keyv": "^5.6.0",
43
+ "qified": "^0.6.0",
44
+ "@cacheable/memory": "^2.0.8",
45
+ "@cacheable/utils": "^2.4.0"
49
46
  },
50
47
  "keywords": [
51
48
  "cacheable",