@keyv/redis 3.0.0 → 4.0.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 +178 -41
- package/dist/index.cjs +421 -0
- package/dist/index.d.cts +210 -0
- package/dist/index.d.ts +210 -0
- package/dist/index.js +388 -0
- package/package.json +79 -77
- package/dist/cjs/index.d.ts +0 -22
- package/dist/cjs/index.js +0 -144
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/types.d.ts +0 -9
- package/dist/cjs/types.js +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/esm/index.d.ts +0 -22
- package/dist/esm/index.js +0 -139
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types.d.ts +0 -9
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import EventEmitter from "events";
|
|
3
|
+
import { createClient } from "redis";
|
|
4
|
+
import { Keyv } from "keyv";
|
|
5
|
+
import {
|
|
6
|
+
createClient as createClient2,
|
|
7
|
+
createCluster
|
|
8
|
+
} from "redis";
|
|
9
|
+
import {
|
|
10
|
+
Keyv as Keyv2
|
|
11
|
+
} from "keyv";
|
|
12
|
+
var KeyvRedis = class extends EventEmitter {
|
|
13
|
+
_client = createClient();
|
|
14
|
+
_namespace;
|
|
15
|
+
_keyPrefixSeparator = "::";
|
|
16
|
+
_clearBatchSize = 1e3;
|
|
17
|
+
_useUnlink = true;
|
|
18
|
+
/**
|
|
19
|
+
* KeyvRedis constructor.
|
|
20
|
+
* @param {string | RedisClientOptions | RedisClientType} [connect] How to connect to the Redis server. If string pass in the url, if object pass in the options, if RedisClient pass in the client.
|
|
21
|
+
* @param {KeyvRedisOptions} [options] Options for the adapter such as namespace, keyPrefixSeparator, and clearBatchSize.
|
|
22
|
+
*/
|
|
23
|
+
constructor(connect, options) {
|
|
24
|
+
super();
|
|
25
|
+
if (connect) {
|
|
26
|
+
if (typeof connect === "string") {
|
|
27
|
+
this._client = createClient({ url: connect });
|
|
28
|
+
} else if (connect.connect !== void 0) {
|
|
29
|
+
this._client = connect;
|
|
30
|
+
} else if (connect instanceof Object) {
|
|
31
|
+
this._client = createClient(connect);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
this.setOptions(options);
|
|
35
|
+
this.initClient();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the Redis client.
|
|
39
|
+
*/
|
|
40
|
+
get client() {
|
|
41
|
+
return this._client;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Set the Redis client.
|
|
45
|
+
*/
|
|
46
|
+
set client(value) {
|
|
47
|
+
this._client = value;
|
|
48
|
+
this.initClient();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the options for the adapter.
|
|
52
|
+
*/
|
|
53
|
+
get opts() {
|
|
54
|
+
return {
|
|
55
|
+
namespace: this._namespace,
|
|
56
|
+
keyPrefixSeparator: this._keyPrefixSeparator,
|
|
57
|
+
clearBatchSize: this._clearBatchSize,
|
|
58
|
+
dialect: "redis",
|
|
59
|
+
url: this._client?.options?.url ?? "redis://localhost:6379"
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Set the options for the adapter.
|
|
64
|
+
*/
|
|
65
|
+
set opts(options) {
|
|
66
|
+
this.setOptions(options);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the namespace for the adapter. If undefined, it will not use a namespace including keyPrefixing.
|
|
70
|
+
* @default undefined
|
|
71
|
+
*/
|
|
72
|
+
get namespace() {
|
|
73
|
+
return this._namespace;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Set the namespace for the adapter. If undefined, it will not use a namespace including keyPrefixing.
|
|
77
|
+
*/
|
|
78
|
+
set namespace(value) {
|
|
79
|
+
this._namespace = value;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the separator between the namespace and key.
|
|
83
|
+
* @default '::'
|
|
84
|
+
*/
|
|
85
|
+
get keyPrefixSeparator() {
|
|
86
|
+
return this._keyPrefixSeparator;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Set the separator between the namespace and key.
|
|
90
|
+
*/
|
|
91
|
+
set keyPrefixSeparator(value) {
|
|
92
|
+
this._keyPrefixSeparator = value;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the number of keys to delete in a single batch.
|
|
96
|
+
* @default 1000
|
|
97
|
+
*/
|
|
98
|
+
get clearBatchSize() {
|
|
99
|
+
return this._clearBatchSize;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Set the number of keys to delete in a single batch.
|
|
103
|
+
*/
|
|
104
|
+
set clearBatchSize(value) {
|
|
105
|
+
this._clearBatchSize = value;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get if Unlink is used instead of Del for clearing keys. This is more performant but may not be supported by all Redis versions.
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
get useUnlink() {
|
|
112
|
+
return this._useUnlink;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Set if Unlink is used instead of Del for clearing keys. This is more performant but may not be supported by all Redis versions.
|
|
116
|
+
*/
|
|
117
|
+
set useUnlink(value) {
|
|
118
|
+
this._useUnlink = value;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get the Redis URL used to connect to the server. This is used to get a connected client.
|
|
122
|
+
*/
|
|
123
|
+
async getClient() {
|
|
124
|
+
if (!this._client.isOpen) {
|
|
125
|
+
await this._client.connect();
|
|
126
|
+
}
|
|
127
|
+
return this._client;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Set a key value pair in the store. TTL is in milliseconds.
|
|
131
|
+
* @param {string} key - the key to set
|
|
132
|
+
* @param {string} value - the value to set
|
|
133
|
+
* @param {number} [ttl] - the time to live in milliseconds
|
|
134
|
+
*/
|
|
135
|
+
async set(key, value, ttl) {
|
|
136
|
+
const client = await this.getClient();
|
|
137
|
+
key = this.createKeyPrefix(key, this._namespace);
|
|
138
|
+
if (ttl) {
|
|
139
|
+
await client.set(key, value, { PX: ttl });
|
|
140
|
+
} else {
|
|
141
|
+
await client.set(key, value);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Will set many key value pairs in the store. TTL is in milliseconds. This will be done as a single transaction.
|
|
146
|
+
* @param {Array<KeyvRedisEntry<string>>} entries - the key value pairs to set with optional ttl
|
|
147
|
+
*/
|
|
148
|
+
async setMany(entries) {
|
|
149
|
+
const client = await this.getClient();
|
|
150
|
+
const multi = client.multi();
|
|
151
|
+
for (const { key, value, ttl } of entries) {
|
|
152
|
+
const prefixedKey = this.createKeyPrefix(key, this._namespace);
|
|
153
|
+
if (ttl) {
|
|
154
|
+
multi.set(prefixedKey, value, { PX: ttl });
|
|
155
|
+
} else {
|
|
156
|
+
multi.set(prefixedKey, value);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
await multi.exec();
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Check if a key exists in the store.
|
|
163
|
+
* @param {string} key - the key to check
|
|
164
|
+
* @returns {Promise<boolean>} - true if the key exists, false if not
|
|
165
|
+
*/
|
|
166
|
+
async has(key) {
|
|
167
|
+
const client = await this.getClient();
|
|
168
|
+
key = this.createKeyPrefix(key, this._namespace);
|
|
169
|
+
const exists = await client.exists(key);
|
|
170
|
+
return exists === 1;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Check if many keys exist in the store. This will be done as a single transaction.
|
|
174
|
+
* @param {Array<string>} keys - the keys to check
|
|
175
|
+
* @returns {Promise<Array<boolean>>} - array of booleans for each key if it exists
|
|
176
|
+
*/
|
|
177
|
+
async hasMany(keys) {
|
|
178
|
+
const client = await this.getClient();
|
|
179
|
+
const multi = client.multi();
|
|
180
|
+
for (const key of keys) {
|
|
181
|
+
const prefixedKey = this.createKeyPrefix(key, this._namespace);
|
|
182
|
+
multi.exists(prefixedKey);
|
|
183
|
+
}
|
|
184
|
+
const results = await multi.exec();
|
|
185
|
+
return results.map((result) => result === 1);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get a value from the store. If the key does not exist, it will return undefined.
|
|
189
|
+
* @param {string} key - the key to get
|
|
190
|
+
* @returns {Promise<string | undefined>} - the value or undefined if the key does not exist
|
|
191
|
+
*/
|
|
192
|
+
async get(key) {
|
|
193
|
+
const client = await this.getClient();
|
|
194
|
+
key = this.createKeyPrefix(key, this._namespace);
|
|
195
|
+
const value = await client.get(key);
|
|
196
|
+
if (value === null) {
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get many values from the store. If a key does not exist, it will return undefined.
|
|
203
|
+
* @param {Array<string>} keys - the keys to get
|
|
204
|
+
* @returns {Promise<Array<string | undefined>>} - array of values or undefined if the key does not exist
|
|
205
|
+
*/
|
|
206
|
+
async getMany(keys) {
|
|
207
|
+
const client = await this.getClient();
|
|
208
|
+
const multi = client.multi();
|
|
209
|
+
for (const key of keys) {
|
|
210
|
+
const prefixedKey = this.createKeyPrefix(key, this._namespace);
|
|
211
|
+
multi.get(prefixedKey);
|
|
212
|
+
}
|
|
213
|
+
const values = await multi.exec();
|
|
214
|
+
return values.map((value) => value === null ? void 0 : value);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Delete a key from the store.
|
|
218
|
+
* @param {string} key - the key to delete
|
|
219
|
+
* @returns {Promise<boolean>} - true if the key was deleted, false if not
|
|
220
|
+
*/
|
|
221
|
+
async delete(key) {
|
|
222
|
+
const client = await this.getClient();
|
|
223
|
+
key = this.createKeyPrefix(key, this._namespace);
|
|
224
|
+
let deleted = 0;
|
|
225
|
+
if (this._useUnlink) {
|
|
226
|
+
deleted = await client.unlink(key);
|
|
227
|
+
} else {
|
|
228
|
+
deleted = await client.del(key);
|
|
229
|
+
}
|
|
230
|
+
return deleted > 0;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Delete many keys from the store. This will be done as a single transaction.
|
|
234
|
+
* @param {Array<string>} keys - the keys to delete
|
|
235
|
+
* @returns {Promise<boolean>} - true if any key was deleted, false if not
|
|
236
|
+
*/
|
|
237
|
+
async deleteMany(keys) {
|
|
238
|
+
let result = false;
|
|
239
|
+
const client = await this.getClient();
|
|
240
|
+
const multi = client.multi();
|
|
241
|
+
for (const key of keys) {
|
|
242
|
+
const prefixedKey = this.createKeyPrefix(key, this._namespace);
|
|
243
|
+
if (this._useUnlink) {
|
|
244
|
+
multi.unlink(prefixedKey);
|
|
245
|
+
} else {
|
|
246
|
+
multi.del(prefixedKey);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const results = await multi.exec();
|
|
250
|
+
for (const deleted of results) {
|
|
251
|
+
if (typeof deleted === "number" && deleted > 0) {
|
|
252
|
+
result = true;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Disconnect from the Redis server.
|
|
259
|
+
* @returns {Promise<void>}
|
|
260
|
+
*/
|
|
261
|
+
async disconnect() {
|
|
262
|
+
if (this._client.isOpen) {
|
|
263
|
+
await this._client.disconnect();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Helper function to create a key with a namespace.
|
|
268
|
+
* @param {string} key - the key to prefix
|
|
269
|
+
* @param {string} namespace - the namespace to prefix the key with
|
|
270
|
+
* @returns {string} - the key with the namespace such as 'namespace::key'
|
|
271
|
+
*/
|
|
272
|
+
createKeyPrefix(key, namespace) {
|
|
273
|
+
if (namespace) {
|
|
274
|
+
return `${namespace}${this._keyPrefixSeparator}${key}`;
|
|
275
|
+
}
|
|
276
|
+
return key;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Helper function to get a key without the namespace.
|
|
280
|
+
* @param {string} key - the key to remove the namespace from
|
|
281
|
+
* @param {string} namespace - the namespace to remove from the key
|
|
282
|
+
* @returns {string} - the key without the namespace such as 'key'
|
|
283
|
+
*/
|
|
284
|
+
getKeyWithoutPrefix(key, namespace) {
|
|
285
|
+
if (namespace) {
|
|
286
|
+
return key.replace(`${namespace}${this._keyPrefixSeparator}`, "");
|
|
287
|
+
}
|
|
288
|
+
return key;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Get an async iterator for the keys and values in the store. If a namespace is provided, it will only iterate over keys with that namespace.
|
|
292
|
+
* @param {string} [namespace] - the namespace to iterate over
|
|
293
|
+
* @returns {AsyncGenerator<[string, T | undefined], void, unknown>} - async iterator with key value pairs
|
|
294
|
+
*/
|
|
295
|
+
async *iterator(namespace) {
|
|
296
|
+
const client = await this.getClient();
|
|
297
|
+
const match = namespace ? `${namespace}${this._keyPrefixSeparator}*` : "*";
|
|
298
|
+
let cursor = "0";
|
|
299
|
+
do {
|
|
300
|
+
const result = await client.scan(Number.parseInt(cursor, 10), { MATCH: match, TYPE: "string" });
|
|
301
|
+
cursor = result.cursor.toString();
|
|
302
|
+
let { keys } = result;
|
|
303
|
+
if (!namespace) {
|
|
304
|
+
keys = keys.filter((key) => !key.includes(this._keyPrefixSeparator));
|
|
305
|
+
}
|
|
306
|
+
if (keys.length > 0) {
|
|
307
|
+
const values = await client.mGet(keys);
|
|
308
|
+
for (const [i] of keys.entries()) {
|
|
309
|
+
const key = this.getKeyWithoutPrefix(keys[i], namespace);
|
|
310
|
+
const value = values ? values[i] : void 0;
|
|
311
|
+
yield [key, value];
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
} while (cursor !== "0");
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Clear all keys in the store.
|
|
318
|
+
* IMPORTANT: this can cause performance issues if there are a large number of keys in the store. Use with caution as not recommended for production.
|
|
319
|
+
* If a namespace is not set it will clear all keys with no prefix.
|
|
320
|
+
* If a namespace is set it will clear all keys with that namespace.
|
|
321
|
+
* @returns {Promise<void>}
|
|
322
|
+
*/
|
|
323
|
+
async clear() {
|
|
324
|
+
await this.clearNamespace(this._namespace);
|
|
325
|
+
}
|
|
326
|
+
async clearNamespace(namespace) {
|
|
327
|
+
try {
|
|
328
|
+
let cursor = "0";
|
|
329
|
+
const batchSize = this._clearBatchSize;
|
|
330
|
+
const match = namespace ? `${namespace}${this._keyPrefixSeparator}*` : "*";
|
|
331
|
+
const client = await this.getClient();
|
|
332
|
+
do {
|
|
333
|
+
const result = await client.scan(Number.parseInt(cursor, 10), { MATCH: match, COUNT: batchSize, TYPE: "string" });
|
|
334
|
+
cursor = result.cursor.toString();
|
|
335
|
+
let { keys } = result;
|
|
336
|
+
if (keys.length === 0) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (!namespace) {
|
|
340
|
+
keys = keys.filter((key) => !key.includes(this._keyPrefixSeparator));
|
|
341
|
+
}
|
|
342
|
+
if (keys.length > 0) {
|
|
343
|
+
if (this._useUnlink) {
|
|
344
|
+
await client.unlink(keys);
|
|
345
|
+
} else {
|
|
346
|
+
await client.del(keys);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
} while (cursor !== "0");
|
|
350
|
+
} catch (error) {
|
|
351
|
+
this.emit("error", error);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
setOptions(options) {
|
|
355
|
+
if (!options) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (options.namespace) {
|
|
359
|
+
this._namespace = options.namespace;
|
|
360
|
+
}
|
|
361
|
+
if (options.keyPrefixSeparator) {
|
|
362
|
+
this._keyPrefixSeparator = options.keyPrefixSeparator;
|
|
363
|
+
}
|
|
364
|
+
if (options.clearBatchSize) {
|
|
365
|
+
this._clearBatchSize = options.clearBatchSize;
|
|
366
|
+
}
|
|
367
|
+
if (options.useUnlink !== void 0) {
|
|
368
|
+
this._useUnlink = options.useUnlink;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
initClient() {
|
|
372
|
+
this._client.on("error", (error) => {
|
|
373
|
+
this.emit("error", error);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
function createKeyv(connect, options) {
|
|
378
|
+
const adapter = new KeyvRedis(connect, options);
|
|
379
|
+
const keyv = new Keyv({ store: adapter, namespace: options?.namespace });
|
|
380
|
+
return keyv;
|
|
381
|
+
}
|
|
382
|
+
export {
|
|
383
|
+
Keyv2 as Keyv,
|
|
384
|
+
createClient2 as createClient,
|
|
385
|
+
createCluster,
|
|
386
|
+
createKeyv,
|
|
387
|
+
KeyvRedis as default
|
|
388
|
+
};
|
package/package.json
CHANGED
|
@@ -1,78 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
2
|
+
"name": "@keyv/redis",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Redis storage adapter for Keyv",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"xo": {
|
|
16
|
+
"rules": {
|
|
17
|
+
"import/no-named-as-default": "off",
|
|
18
|
+
"unicorn/prefer-module": "off",
|
|
19
|
+
"unicorn/prefer-event-target": "off",
|
|
20
|
+
"unicorn/prefer-node-protocol": "off",
|
|
21
|
+
"unicorn/no-typeof-undefined": "off",
|
|
22
|
+
"import/extensions": "off",
|
|
23
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
24
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
25
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
26
|
+
"unicorn/prefer-ternary": "off",
|
|
27
|
+
"unicorn/no-array-callback-reference": "off",
|
|
28
|
+
"import/no-extraneous-dependencies": "off",
|
|
29
|
+
"@typescript-eslint/no-confusing-void-expression": "off"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/jaredwray/keyv.git"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"redis",
|
|
38
|
+
"keyv",
|
|
39
|
+
"storage",
|
|
40
|
+
"adapter",
|
|
41
|
+
"key",
|
|
42
|
+
"value",
|
|
43
|
+
"store",
|
|
44
|
+
"cache",
|
|
45
|
+
"ttl"
|
|
46
|
+
],
|
|
47
|
+
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/jaredwray/keyv/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/jaredwray/keyv",
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"redis": "^4.7.0",
|
|
55
|
+
"keyv": "*"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@keyv/test-suite": "*",
|
|
59
|
+
"rimraf": "^6.0.1",
|
|
60
|
+
"timekeeper": "^2.3.1",
|
|
61
|
+
"tsd": "^0.31.2",
|
|
62
|
+
"xo": "^0.59.3"
|
|
63
|
+
},
|
|
64
|
+
"tsd": {
|
|
65
|
+
"directory": "test"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">= 18"
|
|
69
|
+
},
|
|
70
|
+
"files": [
|
|
71
|
+
"dist",
|
|
72
|
+
"LICENSE"
|
|
73
|
+
],
|
|
74
|
+
"scripts": {
|
|
75
|
+
"build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
|
|
76
|
+
"test": "xo --fix && vitest run --coverage",
|
|
77
|
+
"test:ci": "xo && vitest --run --sequence.setupFiles=list",
|
|
78
|
+
"clean": "rimraf ./node_modules ./coverage ./dist"
|
|
79
|
+
}
|
|
80
|
+
}
|
package/dist/cjs/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'events';
|
|
2
|
-
import { type KeyvStoreAdapter, type StoredData } from 'keyv';
|
|
3
|
-
import { type KeyvRedisOptions, type KeyvUriOptions } from './types.js';
|
|
4
|
-
declare class KeyvRedis extends EventEmitter implements KeyvStoreAdapter {
|
|
5
|
-
ttlSupport: boolean;
|
|
6
|
-
namespace?: string;
|
|
7
|
-
opts: Record<string, unknown>;
|
|
8
|
-
redis: any;
|
|
9
|
-
constructor(uri: KeyvRedisOptions | KeyvUriOptions, options?: KeyvRedisOptions);
|
|
10
|
-
_getNamespace(): string;
|
|
11
|
-
_getKeyName: (key: string) => string;
|
|
12
|
-
get<Value>(key: string): Promise<StoredData<Value> | undefined>;
|
|
13
|
-
getMany<Value>(keys: string[]): Promise<Array<StoredData<Value | undefined>>>;
|
|
14
|
-
set(key: string, value: any, ttl?: number): Promise<undefined>;
|
|
15
|
-
delete(key: string): Promise<boolean>;
|
|
16
|
-
deleteMany(keys: string[]): Promise<boolean>;
|
|
17
|
-
clear(): Promise<void>;
|
|
18
|
-
iterator(namespace?: string): AsyncGenerator<any[], void, unknown>;
|
|
19
|
-
has(key: string): Promise<boolean>;
|
|
20
|
-
disconnect(): Promise<any>;
|
|
21
|
-
}
|
|
22
|
-
export default KeyvRedis;
|