@keyv/redis 5.1.4 → 5.1.5
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 +8 -0
- package/package.json +19 -13
package/README.md
CHANGED
|
@@ -218,6 +218,14 @@ const keyv = createKeyvNonBlocking('redis://user:pass@localhost:6379');
|
|
|
218
218
|
|
|
219
219
|
# Namespaces
|
|
220
220
|
|
|
221
|
+
By default namespacing is turned off, this is done because it causes much more memory / performance usage for Redis.
|
|
222
|
+
|
|
223
|
+
Redis does **not** treat colons (`:`) or namespaces as special—there are no hierarchical keys or namespace mechanics internally. The dramatic memory savings you see when removing prefixes like `namespace:` come from one thing: **key length**. Redis stores every key as a full string in memory, wrapped in an SDS structure and allocated by jemalloc. Longer keys (e.g., `namespace:key123`) fall into larger jemalloc size classes, require more bytes for the SDS header, and cause more fragmentation. Shorter keys (e.g., `key123`) fit into much smaller slabs, pack tightly, and result in far more stable and predictable memory usage.
|
|
224
|
+
|
|
225
|
+
This means the colon is not the issue—**the extra characters are.** A key that goes from ~18 bytes to ~6 bytes can use *half the memory per key* once overhead, allocator classes, and fragmentation are considered. Multiply that by hundreds of thousands or millions of keys, and memory usage becomes significantly smaller and much more stable simply because the keys are shorter.
|
|
226
|
+
|
|
227
|
+
## How to use Namespaces
|
|
228
|
+
|
|
221
229
|
You can set a namespace for your keys. This is useful if you want to manage your keys in a more organized way. Here is an example of how to set a `namespace` with the `store` option:
|
|
222
230
|
|
|
223
231
|
```js
|
package/package.json
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/redis",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5",
|
|
4
4
|
"description": "Redis storage adapter for Keyv",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"require":
|
|
12
|
-
|
|
11
|
+
"require": {
|
|
12
|
+
"types": "./dist/index.d.cts",
|
|
13
|
+
"default": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
13
19
|
}
|
|
14
20
|
},
|
|
15
21
|
"repository": {
|
|
@@ -34,21 +40,21 @@
|
|
|
34
40
|
},
|
|
35
41
|
"homepage": "https://github.com/jaredwray/keyv",
|
|
36
42
|
"dependencies": {
|
|
37
|
-
"@redis/client": "^5.
|
|
43
|
+
"@redis/client": "^5.10.0",
|
|
38
44
|
"cluster-key-slot": "^1.1.2",
|
|
39
|
-
"hookified": "^1.
|
|
45
|
+
"hookified": "^1.13.0"
|
|
40
46
|
},
|
|
41
47
|
"peerDependencies": {
|
|
42
|
-
"keyv": "^5.5.
|
|
48
|
+
"keyv": "^5.5.5"
|
|
43
49
|
},
|
|
44
50
|
"devDependencies": {
|
|
45
|
-
"@biomejs/biome": "^2.3.
|
|
51
|
+
"@biomejs/biome": "^2.3.8",
|
|
46
52
|
"@faker-js/faker": "^10.1.0",
|
|
47
|
-
"@vitest/coverage-v8": "^4.0.
|
|
48
|
-
"rimraf": "^6.1.
|
|
53
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
54
|
+
"rimraf": "^6.1.2",
|
|
49
55
|
"timekeeper": "^2.3.1",
|
|
50
56
|
"tsd": "^0.33.0",
|
|
51
|
-
"vitest": "^4.0.
|
|
57
|
+
"vitest": "^4.0.15",
|
|
52
58
|
"@keyv/test-suite": "^2.1.2"
|
|
53
59
|
},
|
|
54
60
|
"tsd": {
|