keyv 5.5.5 → 5.6.0

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
@@ -3,6 +3,7 @@
3
3
  > Simple key-value storage with support for multiple backends
4
4
 
5
5
  [![build](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml)
6
+ [![bun](https://github.com/jaredwray/keyv/actions/workflows/bun-test.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/bun-test.yaml)
6
7
  [![codecov](https://codecov.io/gh/jaredwray/keyv/branch/main/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv)
7
8
  [![npm](https://img.shields.io/npm/dm/keyv.svg)](https://www.npmjs.com/package/keyv)
8
9
  [![npm](https://img.shields.io/npm/v/keyv.svg)](https://www.npmjs.com/package/keyv)
@@ -24,7 +25,12 @@ There are a few existing modules similar to Keyv, however Keyv is different beca
24
25
  - Connection errors are passed through (db failures won't kill your app)
25
26
  - Supports the current active LTS version of Node.js or higher
26
27
 
28
+ # Bun Support
29
+
30
+ We make a best effort to support [Bun](https://bun.sh/) as a runtime. Our default and primary target is Node.js, but we run tests against Bun to ensure compatibility. If you encounter any issues while using Keyv with Bun, please report them at our [GitHub issues](https://github.com/jaredwray/keyv/issues).
31
+
27
32
  # Table of Contents
33
+ - [Bun Support](#bun-support)
28
34
  - [Usage](#usage)
29
35
  - [Type-safe Usage](#type-safe-usage)
30
36
  - [Using Storage Adapters](#using-storage-adapters)
@@ -324,6 +330,8 @@ DynamoDB | [@keyv/dynamo](https://github.com/jaredwray/keyv/tree/master/packages
324
330
 
325
331
  # Third-party Storage Adapters
326
332
 
333
+ We love the community and the third-party storage adapters they have built. They enable Keyv to be used with even more backends and use cases.
334
+
327
335
  You can also use third-party storage adapters or build your own. Keyv will wrap these storage adapters in TTL functionality and handle complex types internally.
328
336
 
329
337
  ```js
@@ -349,22 +357,7 @@ const lru = new QuickLRU({ maxSize: 1000 });
349
357
  const keyv = new Keyv({ store: lru });
350
358
  ```
351
359
 
352
- The following are third-party storage adapters compatible with Keyv:
353
-
354
- - [@resolid/keyv-sqlite](https://github.com/huijiewei/keyv-sqlite) - A new SQLite storage adapter for Keyv
355
- - [keyv-arango](https://github.com/TimMikeladze/keyv-arango) - ArangoDB storage adapter for Keyv
356
- - [keyv-azuretable](https://github.com/howlowck/keyv-azuretable) - Azure Table Storage/API adapter for Keyv
357
- - [keyv-browser](https://github.com/zaaack/keyv-browser) - Browser storage adapter for Keyv, including localStorage and indexedDB.
358
- - [keyv-cloudflare](https://npm.im/keyv-cloudflare) - Storage adapter for Cloudflare Workers KV
359
- - [keyv-dynamodb](https://www.npmjs.com/package/keyv-dynamodb) - DynamoDB storage adapter for Keyv
360
- - [keyv-file](https://github.com/zaaack/keyv-file) - File system storage adapter for Keyv
361
- - [keyv-firestore ](https://github.com/goto-bus-stop/keyv-firestore) – Firebase Cloud Firestore adapter for Keyv
362
- - [keyv-lru](https://www.npmjs.com/package/keyv-lru) - LRU storage adapter for Keyv
363
- - [keyv-momento](https://github.com/momentohq/node-keyv-adaptor/) - Momento storage adapter for Keyv
364
- - [keyv-mssql](https://github.com/pmorgan3/keyv-mssql) - Microsoft Sql Server adapter for Keyv
365
- - [keyv-null](https://www.npmjs.com/package/keyv-null) - Null storage adapter for Keyv
366
- - [keyv-upstash](https://github.com/mahdavipanah/keyv-upstash) - Upstash Redis adapter for Keyv
367
- - [quick-lru](https://github.com/sindresorhus/quick-lru) - Simple "Least Recently Used" (LRU) cache
360
+ View the complete list of third-party storage adapters and learn how to build your own at https://keyv.org/docs/third-party-storage-adapters/
368
361
 
369
362
  # Using BigMap to Scale
370
363
 
package/dist/index.cjs CHANGED
@@ -476,7 +476,7 @@ var Keyv = class extends event_manager_default {
476
476
  continue;
477
477
  }
478
478
  if (typeof data.expires === "number" && Date.now() > data.expires) {
479
- this.delete(key);
479
+ await this.delete(key);
480
480
  continue;
481
481
  }
482
482
  yield [this._getKeyUnprefix(key), data.value];
@@ -496,6 +496,9 @@ var Keyv = class extends event_manager_default {
496
496
  if (!this._namespace) {
497
497
  return key;
498
498
  }
499
+ if (key.startsWith(`${this._namespace}:`)) {
500
+ return key;
501
+ }
499
502
  return `${this._namespace}:${key}`;
500
503
  }
501
504
  _getKeyPrefixArray(keys) {
package/dist/index.js CHANGED
@@ -450,7 +450,7 @@ var Keyv = class extends event_manager_default {
450
450
  continue;
451
451
  }
452
452
  if (typeof data.expires === "number" && Date.now() > data.expires) {
453
- this.delete(key);
453
+ await this.delete(key);
454
454
  continue;
455
455
  }
456
456
  yield [this._getKeyUnprefix(key), data.value];
@@ -470,6 +470,9 @@ var Keyv = class extends event_manager_default {
470
470
  if (!this._namespace) {
471
471
  return key;
472
472
  }
473
+ if (key.startsWith(`${this._namespace}:`)) {
474
+ return key;
475
+ }
473
476
  return `${this._namespace}:${key}`;
474
477
  }
475
478
  _getKeyPrefixArray(keys) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keyv",
3
- "version": "5.5.5",
3
+ "version": "5.6.0",
4
4
  "description": "Simple key-value storage with support for multiple backends",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -53,6 +53,8 @@
53
53
  "@keyv/serialize": "^1.1.1"
54
54
  },
55
55
  "devDependencies": {
56
+ "lru.min": "^1.1.1",
57
+ "quick-lru": "^7.0.0",
56
58
  "@biomejs/biome": "^2.3.8",
57
59
  "@faker-js/faker": "^10.1.0",
58
60
  "@vitest/coverage-v8": "^4.0.14",
@@ -60,13 +62,13 @@
60
62
  "timekeeper": "^2.3.1",
61
63
  "tsd": "^0.33.0",
62
64
  "vitest": "^4.0.14",
63
- "@keyv/mongo": "^3.0.5",
64
- "@keyv/memcache": "^2.0.2",
65
- "@keyv/compress-brotli": "^2.0.5",
65
+ "@keyv/compress-gzip": "^2.0.3",
66
66
  "@keyv/sqlite": "^4.0.6",
67
+ "@keyv/test-suite": "^2.1.2",
68
+ "@keyv/mongo": "^3.1.0",
69
+ "@keyv/compress-brotli": "^2.0.5",
67
70
  "@keyv/compress-lz4": "^1.0.1",
68
- "@keyv/compress-gzip": "^2.0.3",
69
- "@keyv/test-suite": "^2.1.2"
71
+ "@keyv/memcache": "^2.0.2"
70
72
  },
71
73
  "tsd": {
72
74
  "directory": "test"