@naturalcycles/redis-lib 3.3.0 → 3.3.2
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/dist/redisClient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyObject, CommonLogger, NullableBuffer, NullableString, Promisable,
|
|
1
|
+
import { AnyObject, CommonLogger, NullableBuffer, NullableString, Promisable, UnixTimestamp } from '@naturalcycles/js-lib';
|
|
2
2
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
3
3
|
import type { Redis, RedisOptions } from 'ioredis';
|
|
4
4
|
import type { ScanStreamOptions } from 'ioredis/built/types';
|
|
@@ -48,8 +48,8 @@ export declare class RedisClient implements CommonClient {
|
|
|
48
48
|
hmgetBuffer(key: string, fields: string[]): Promise<NullableBuffer[]>;
|
|
49
49
|
hincr(key: string, field: string, increment?: number): Promise<number>;
|
|
50
50
|
hincrBatch(key: string, incrementTuples: [string, number][]): Promise<[string, number][]>;
|
|
51
|
-
setWithTTL(key: string, value: string | number | Buffer, expireAt:
|
|
52
|
-
hsetWithTTL(_key: string, _value: AnyObject, _expireAt:
|
|
51
|
+
setWithTTL(key: string, value: string | number | Buffer, expireAt: UnixTimestamp): Promise<void>;
|
|
52
|
+
hsetWithTTL(_key: string, _value: AnyObject, _expireAt: UnixTimestamp): Promise<void>;
|
|
53
53
|
mset(obj: Record<string, string | number>): Promise<void>;
|
|
54
54
|
msetBuffer(obj: Record<string, Buffer>): Promise<void>;
|
|
55
55
|
incr(key: string, by?: number): Promise<number>;
|
|
@@ -13,7 +13,7 @@ import { RedisKeyValueDBCfg } from './redisKeyValueDB';
|
|
|
13
13
|
* Once the available Redis version reaches 7.4.0+,
|
|
14
14
|
* this implementation can take over for RedisKeyValueDB.
|
|
15
15
|
*/
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class RedisHashKeyValueDB implements CommonKeyValueDB, AsyncDisposable {
|
|
17
17
|
cfg: RedisKeyValueDBCfg;
|
|
18
18
|
constructor(cfg: RedisKeyValueDBCfg);
|
|
19
19
|
support: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RedisHashKeyValueDB = void 0;
|
|
4
4
|
const db_lib_1 = require("@naturalcycles/db-lib");
|
|
5
5
|
/**
|
|
6
6
|
* RedisHashKeyValueDB is a KeyValueDB implementation that uses hash fields to simulate tables.
|
|
@@ -14,7 +14,7 @@ const db_lib_1 = require("@naturalcycles/db-lib");
|
|
|
14
14
|
* Once the available Redis version reaches 7.4.0+,
|
|
15
15
|
* this implementation can take over for RedisKeyValueDB.
|
|
16
16
|
*/
|
|
17
|
-
class
|
|
17
|
+
class RedisHashKeyValueDB {
|
|
18
18
|
constructor(cfg) {
|
|
19
19
|
this.cfg = cfg;
|
|
20
20
|
this.support = {
|
|
@@ -102,4 +102,4 @@ class RedishHashKeyValueDB {
|
|
|
102
102
|
await this.cfg.client.del([table]);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
exports.
|
|
105
|
+
exports.RedisHashKeyValueDB = RedisHashKeyValueDB;
|
package/package.json
CHANGED
package/src/redisClient.ts
CHANGED
|
@@ -6,12 +6,10 @@ import {
|
|
|
6
6
|
NullableString,
|
|
7
7
|
Promisable,
|
|
8
8
|
StringMap,
|
|
9
|
-
|
|
9
|
+
UnixTimestamp,
|
|
10
10
|
} from '@naturalcycles/js-lib'
|
|
11
11
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
12
|
-
// eslint-disable-next-line import-x/no-duplicates
|
|
13
12
|
import type { Redis, RedisOptions } from 'ioredis'
|
|
14
|
-
// eslint-disable-next-line import-x/no-duplicates
|
|
15
13
|
import type * as RedisLib from 'ioredis'
|
|
16
14
|
import type { ScanStreamOptions } from 'ioredis/built/types'
|
|
17
15
|
import type { ChainableCommander } from 'ioredis/built/utils/RedisCommander'
|
|
@@ -181,16 +179,12 @@ export class RedisClient implements CommonClient {
|
|
|
181
179
|
async setWithTTL(
|
|
182
180
|
key: string,
|
|
183
181
|
value: string | number | Buffer,
|
|
184
|
-
expireAt:
|
|
182
|
+
expireAt: UnixTimestamp,
|
|
185
183
|
): Promise<void> {
|
|
186
184
|
await this.redis().set(key, value, 'EXAT', expireAt)
|
|
187
185
|
}
|
|
188
186
|
|
|
189
|
-
async hsetWithTTL(
|
|
190
|
-
_key: string,
|
|
191
|
-
_value: AnyObject,
|
|
192
|
-
_expireAt: UnixTimestampNumber,
|
|
193
|
-
): Promise<void> {
|
|
187
|
+
async hsetWithTTL(_key: string, _value: AnyObject, _expireAt: UnixTimestamp): Promise<void> {
|
|
194
188
|
throw new Error('Not supported until Redis 7.4.0')
|
|
195
189
|
// const valueKeys = Object.keys(value)
|
|
196
190
|
// const numberOfKeys = valueKeys.length
|
|
@@ -21,7 +21,7 @@ import { RedisKeyValueDBCfg } from './redisKeyValueDB'
|
|
|
21
21
|
* Once the available Redis version reaches 7.4.0+,
|
|
22
22
|
* this implementation can take over for RedisKeyValueDB.
|
|
23
23
|
*/
|
|
24
|
-
export class
|
|
24
|
+
export class RedisHashKeyValueDB implements CommonKeyValueDB, AsyncDisposable {
|
|
25
25
|
constructor(public cfg: RedisKeyValueDBCfg) {}
|
|
26
26
|
|
|
27
27
|
support = {
|