@forklaunch/infrastructure-redis 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 forklaunch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,373 @@
1
+ import { safeParse, safeStringify } from '@forklaunch/common';
2
+ import { TtlCache, TtlCacheRecord } from '@forklaunch/core/cache';
3
+ import {
4
+ evaluateTelemetryOptions,
5
+ MetricsDefinition,
6
+ OpenTelemetryCollector,
7
+ TelemetryOptions
8
+ } from '@forklaunch/core/http';
9
+ import { createClient, RedisClientOptions } from 'redis';
10
+
11
+ /**
12
+ * Type representing a raw reply from Redis commands.
13
+ * Can be a string, number, Buffer, null, undefined, or array of raw replies.
14
+ */
15
+ type RedisCommandRawReply =
16
+ | string
17
+ | number
18
+ | Buffer
19
+ | null
20
+ | undefined
21
+ | Array<RedisCommandRawReply>;
22
+
23
+ /**
24
+ * Class representing a Redis-based TTL (Time-To-Live) cache.
25
+ * Implements the TtlCache interface to provide caching functionality with automatic expiration.
26
+ */
27
+ export class RedisTtlCache implements TtlCache {
28
+ private client;
29
+ private telemetryOptions;
30
+
31
+ /**
32
+ * Creates an instance of RedisTtlCache.
33
+ *
34
+ * @param {number} ttlMilliseconds - The default Time-To-Live in milliseconds for cache entries
35
+ * @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics
36
+ * @param {RedisClientOptions} hostingOptions - Configuration options for the Redis client
37
+ * @param {TelemetryOptions} telemetryOptions - Configuration options for telemetry
38
+ */
39
+ constructor(
40
+ private ttlMilliseconds: number,
41
+ private openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
42
+ options: RedisClientOptions,
43
+ telemetryOptions: TelemetryOptions
44
+ ) {
45
+ this.telemetryOptions = evaluateTelemetryOptions(telemetryOptions);
46
+ this.client = createClient(options);
47
+ if (this.telemetryOptions.enabled.logging) {
48
+ this.client.on('error', (err) => this.openTelemetryCollector.error(err));
49
+ this.client.connect().catch(this.openTelemetryCollector.error);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Parses a raw Redis reply into the expected type.
55
+ * Handles null values, arrays, buffers, and JSON strings.
56
+ *
57
+ * @template T - The expected type of the parsed value
58
+ * @param {RedisCommandRawReply} value - The raw value from Redis to parse
59
+ * @returns {T} The parsed value cast to type T
60
+ */
61
+ private parseValue<T>(value: RedisCommandRawReply): T {
62
+ if (value == null) {
63
+ return null as T;
64
+ }
65
+
66
+ if (Array.isArray(value)) {
67
+ return value.map((v) => this.parseValue<T>(v)) as T;
68
+ }
69
+
70
+ if (Buffer.isBuffer(value)) {
71
+ return value.toJSON() as T;
72
+ }
73
+
74
+ switch (typeof value) {
75
+ case 'object':
76
+ case 'string':
77
+ return safeParse(value) as T;
78
+ case 'number':
79
+ return value as T;
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Puts a record into the Redis cache.
85
+ *
86
+ * @template T - The type of value being cached
87
+ * @param {TtlCacheRecord<T>} param0 - The cache record containing key, value and optional TTL
88
+ * @param {string} param0.key - The key to store the value under
89
+ * @param {T} param0.value - The value to cache
90
+ * @param {number} [param0.ttlMilliseconds] - Optional TTL in milliseconds, defaults to constructor value
91
+ * @returns {Promise<void>} A promise that resolves when the value is cached
92
+ */
93
+ async putRecord<T>({
94
+ key,
95
+ value,
96
+ ttlMilliseconds = this.ttlMilliseconds
97
+ }: TtlCacheRecord<T>): Promise<void> {
98
+ if (this.telemetryOptions.enabled.logging) {
99
+ this.openTelemetryCollector.info(`Putting record into cache: ${key}`);
100
+ }
101
+ await this.client.set(key, safeStringify(value), {
102
+ PX: ttlMilliseconds
103
+ });
104
+ }
105
+
106
+ /**
107
+ * Puts multiple records into the Redis cache in a single transaction.
108
+ *
109
+ * @template T - The type of values being cached
110
+ * @param {TtlCacheRecord<T>[]} cacheRecords - Array of cache records to store
111
+ * @returns {Promise<void>} A promise that resolves when all values are cached
112
+ */
113
+ async putBatchRecords<T>(cacheRecords: TtlCacheRecord<T>[]): Promise<void> {
114
+ const multiCommand = this.client.multi();
115
+ for (const { key, value, ttlMilliseconds } of cacheRecords) {
116
+ multiCommand.set(key, safeStringify(value), {
117
+ PX: ttlMilliseconds || this.ttlMilliseconds
118
+ });
119
+ }
120
+ await multiCommand.exec();
121
+ }
122
+
123
+ /**
124
+ * Adds a value to the left end of a Redis list.
125
+ *
126
+ * @template T - The type of value being enqueued
127
+ * @param {string} queueName - The name of the Redis list
128
+ * @param {T} value - The value to add to the list
129
+ * @returns {Promise<void>} A promise that resolves when the value is enqueued
130
+ */
131
+ async enqueueRecord<T>(queueName: string, value: T): Promise<void> {
132
+ await this.client.lPush(queueName, safeStringify(value));
133
+ }
134
+
135
+ /**
136
+ * Adds multiple values to the left end of a Redis list in a single transaction.
137
+ *
138
+ * @template T - The type of values being enqueued
139
+ * @param {string} queueName - The name of the Redis list
140
+ * @param {T[]} values - Array of values to add to the list
141
+ * @returns {Promise<void>} A promise that resolves when all values are enqueued
142
+ */
143
+ async enqueueBatchRecords<T>(queueName: string, values: T[]): Promise<void> {
144
+ const multiCommand = this.client.multi();
145
+ for (const value of values) {
146
+ multiCommand.lPush(queueName, safeStringify(value));
147
+ }
148
+ await multiCommand.exec();
149
+ }
150
+
151
+ /**
152
+ * Deletes a record from the Redis cache.
153
+ *
154
+ * @param {string} cacheRecordKey - The key of the record to delete
155
+ * @returns {Promise<void>} A promise that resolves when the record is deleted
156
+ */
157
+ async deleteRecord(cacheRecordKey: string): Promise<void> {
158
+ await this.client.del(cacheRecordKey);
159
+ }
160
+
161
+ /**
162
+ * Deletes multiple records from the Redis cache in a single transaction.
163
+ *
164
+ * @param {string[]} cacheRecordKeys - Array of keys to delete
165
+ * @returns {Promise<void>} A promise that resolves when all records are deleted
166
+ */
167
+ async deleteBatchRecords(cacheRecordKeys: string[]): Promise<void> {
168
+ const multiCommand = this.client.multi();
169
+ for (const key of cacheRecordKeys) {
170
+ multiCommand.del(key);
171
+ }
172
+ await multiCommand.exec();
173
+ }
174
+
175
+ /**
176
+ * Removes and returns the rightmost element from a Redis list.
177
+ *
178
+ * @template T - The type of value being dequeued
179
+ * @param {string} queueName - The name of the Redis list
180
+ * @returns {Promise<T>} A promise that resolves with the dequeued value
181
+ * @throws {Error} If the queue is empty
182
+ */
183
+ async dequeueRecord<T>(queueName: string): Promise<T> {
184
+ const value = await this.client.rPop(queueName);
185
+ if (value === null) {
186
+ throw new Error(`Queue is empty: ${queueName}`);
187
+ }
188
+ return safeParse(value) as T;
189
+ }
190
+
191
+ /**
192
+ * Removes and returns multiple elements from the right end of a Redis list.
193
+ *
194
+ * @template T - The type of values being dequeued
195
+ * @param {string} queueName - The name of the Redis list
196
+ * @param {number} pageSize - Maximum number of elements to dequeue
197
+ * @returns {Promise<T[]>} A promise that resolves with an array of dequeued values
198
+ */
199
+ async dequeueBatchRecords<T>(
200
+ queueName: string,
201
+ pageSize: number
202
+ ): Promise<T[]> {
203
+ const multiCommand = this.client.multi();
204
+ for (let i = 0; i < pageSize; i++) {
205
+ multiCommand.rPop(queueName);
206
+ }
207
+ const values = await multiCommand.exec();
208
+ return values
209
+ .map((value) =>
210
+ this.parseValue<T>(value as unknown as RedisCommandRawReply)
211
+ )
212
+ .filter(Boolean);
213
+ }
214
+
215
+ /**
216
+ * Reads a record from the Redis cache.
217
+ *
218
+ * @template T - The type of value being read
219
+ * @param {string} cacheRecordKey - The key of the record to read
220
+ * @returns {Promise<TtlCacheRecord<T>>} A promise that resolves with the cache record
221
+ * @throws {Error} If the record is not found
222
+ */
223
+ async readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>> {
224
+ const [value, ttl] = await this.client
225
+ .multi()
226
+ .get(cacheRecordKey)
227
+ .ttl(cacheRecordKey)
228
+ .exec();
229
+ if (value === null) {
230
+ throw new Error(`Record not found for key: ${cacheRecordKey}`);
231
+ }
232
+
233
+ return {
234
+ key: cacheRecordKey,
235
+ value: this.parseValue<T>(value as unknown as RedisCommandRawReply),
236
+ ttlMilliseconds:
237
+ this.parseValue<number>(ttl as unknown as RedisCommandRawReply) * 1000
238
+ };
239
+ }
240
+
241
+ /**
242
+ * Reads multiple records from the Redis cache.
243
+ *
244
+ * @template T - The type of values being read
245
+ * @param {string[] | string} cacheRecordKeysOrPrefix - Array of keys to read, or a prefix pattern
246
+ * @returns {Promise<TtlCacheRecord<T>[]>} A promise that resolves with an array of cache records
247
+ */
248
+ async readBatchRecords<T>(
249
+ cacheRecordKeysOrPrefix: string[] | string
250
+ ): Promise<TtlCacheRecord<T>[]> {
251
+ const keys = Array.isArray(cacheRecordKeysOrPrefix)
252
+ ? cacheRecordKeysOrPrefix
253
+ : await this.client.keys(cacheRecordKeysOrPrefix + '*');
254
+ const multiCommand = this.client.multi();
255
+ for (const key of keys) {
256
+ multiCommand.get(key);
257
+ multiCommand.ttl(key);
258
+ }
259
+ const values = await multiCommand.exec();
260
+ return values.reduce<TtlCacheRecord<T>[]>((acc, value, index) => {
261
+ if (index % 2 === 0) {
262
+ const maybeValue = this.parseValue<T>(
263
+ value as unknown as RedisCommandRawReply
264
+ );
265
+ const ttl = this.parseValue<number>(
266
+ values[index + 1] as unknown as RedisCommandRawReply
267
+ );
268
+ if (maybeValue && ttl) {
269
+ acc.push({
270
+ key: keys[index / 2],
271
+ value: maybeValue,
272
+ ttlMilliseconds: ttl * 1000
273
+ });
274
+ }
275
+ }
276
+ return acc;
277
+ }, []);
278
+ }
279
+
280
+ /**
281
+ * Lists all keys in the Redis cache that match a pattern prefix.
282
+ *
283
+ * @param {string} pattern_prefix - The prefix pattern to match keys against
284
+ * @returns {Promise<string[]>} A promise that resolves with an array of matching keys
285
+ */
286
+ async listKeys(pattern_prefix: string): Promise<string[]> {
287
+ const keys = await this.client.keys(pattern_prefix + '*');
288
+ return keys;
289
+ }
290
+
291
+ /**
292
+ * Checks if a record exists in the Redis cache.
293
+ *
294
+ * @param {string} cacheRecordKey - The key to check
295
+ * @returns {Promise<boolean>} A promise that resolves with true if the record exists, false otherwise
296
+ */
297
+ async peekRecord(cacheRecordKey: string): Promise<boolean> {
298
+ const result = await this.client.exists(cacheRecordKey);
299
+ return result === 1;
300
+ }
301
+
302
+ /**
303
+ * Checks if multiple records exist in the Redis cache.
304
+ *
305
+ * @param {string[] | string} cacheRecordKeysOrPrefix - Array of keys to check, or a prefix pattern
306
+ * @returns {Promise<boolean[]>} A promise that resolves with an array of existence booleans
307
+ */
308
+ async peekBatchRecords(
309
+ cacheRecordKeysOrPrefix: string[] | string
310
+ ): Promise<boolean[]> {
311
+ const keys = Array.isArray(cacheRecordKeysOrPrefix)
312
+ ? cacheRecordKeysOrPrefix
313
+ : await this.client.keys(cacheRecordKeysOrPrefix + '*');
314
+ const multiCommand = this.client.multi();
315
+ for (const key of keys) {
316
+ multiCommand.exists(key);
317
+ }
318
+ const results = await multiCommand.exec();
319
+ return results.map((result) => (result as unknown as number) === 1);
320
+ }
321
+
322
+ /**
323
+ * Peeks at a record in the Redis cache.
324
+ *
325
+ * @template T - The type of value being peeked at
326
+ * @param {string} queueName - The name of the Redis queue
327
+ * @returns {Promise<T>} A promise that resolves with the peeked value
328
+ */
329
+ async peekQueueRecord<T>(queueName: string): Promise<T> {
330
+ const value = await this.client.lRange(queueName, 0, 0);
331
+ return this.parseValue<T>(value[0]);
332
+ }
333
+
334
+ /**
335
+ * Peeks at multiple records in the Redis cache.
336
+ *
337
+ * @template T - The type of values being peeked at
338
+ * @param {string} queueName - The name of the Redis queue
339
+ * @param {number} pageSize - The number of records to peek at
340
+ * @returns {Promise<T[]>} A promise that resolves with an array of peeked values
341
+ */
342
+ async peekQueueRecords<T>(queueName: string, pageSize: number): Promise<T[]> {
343
+ const values = await this.client.lRange(queueName, 0, pageSize - 1);
344
+ return values.map((value) => this.parseValue<T>(value)).filter(Boolean);
345
+ }
346
+
347
+ /**
348
+ * Gracefully disconnects from the Redis server.
349
+ *
350
+ * @returns {Promise<void>} A promise that resolves when the connection is closed
351
+ */
352
+ async disconnect(): Promise<void> {
353
+ await this.client.quit();
354
+ }
355
+
356
+ /**
357
+ * Gets the default Time-To-Live value in milliseconds.
358
+ *
359
+ * @returns {number} The default TTL in milliseconds
360
+ */
361
+ getTtlMilliseconds(): number {
362
+ return this.ttlMilliseconds;
363
+ }
364
+
365
+ /**
366
+ * Gets the underlying Redis client instance.
367
+ *
368
+ * @returns {typeof this.client} The Redis client instance
369
+ */
370
+ getClient(): typeof this.client {
371
+ return this.client;
372
+ }
373
+ }
@@ -0,0 +1,176 @@
1
+ import { TtlCache, TtlCacheRecord } from '@forklaunch/core/cache';
2
+ import { OpenTelemetryCollector, MetricsDefinition, TelemetryOptions } from '@forklaunch/core/http';
3
+ import { RedisClientOptions } from 'redis';
4
+
5
+ /**
6
+ * Class representing a Redis-based TTL (Time-To-Live) cache.
7
+ * Implements the TtlCache interface to provide caching functionality with automatic expiration.
8
+ */
9
+ declare class RedisTtlCache implements TtlCache {
10
+ private ttlMilliseconds;
11
+ private openTelemetryCollector;
12
+ private client;
13
+ private telemetryOptions;
14
+ /**
15
+ * Creates an instance of RedisTtlCache.
16
+ *
17
+ * @param {number} ttlMilliseconds - The default Time-To-Live in milliseconds for cache entries
18
+ * @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics
19
+ * @param {RedisClientOptions} hostingOptions - Configuration options for the Redis client
20
+ * @param {TelemetryOptions} telemetryOptions - Configuration options for telemetry
21
+ */
22
+ constructor(ttlMilliseconds: number, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options: RedisClientOptions, telemetryOptions: TelemetryOptions);
23
+ /**
24
+ * Parses a raw Redis reply into the expected type.
25
+ * Handles null values, arrays, buffers, and JSON strings.
26
+ *
27
+ * @template T - The expected type of the parsed value
28
+ * @param {RedisCommandRawReply} value - The raw value from Redis to parse
29
+ * @returns {T} The parsed value cast to type T
30
+ */
31
+ private parseValue;
32
+ /**
33
+ * Puts a record into the Redis cache.
34
+ *
35
+ * @template T - The type of value being cached
36
+ * @param {TtlCacheRecord<T>} param0 - The cache record containing key, value and optional TTL
37
+ * @param {string} param0.key - The key to store the value under
38
+ * @param {T} param0.value - The value to cache
39
+ * @param {number} [param0.ttlMilliseconds] - Optional TTL in milliseconds, defaults to constructor value
40
+ * @returns {Promise<void>} A promise that resolves when the value is cached
41
+ */
42
+ putRecord<T>({ key, value, ttlMilliseconds }: TtlCacheRecord<T>): Promise<void>;
43
+ /**
44
+ * Puts multiple records into the Redis cache in a single transaction.
45
+ *
46
+ * @template T - The type of values being cached
47
+ * @param {TtlCacheRecord<T>[]} cacheRecords - Array of cache records to store
48
+ * @returns {Promise<void>} A promise that resolves when all values are cached
49
+ */
50
+ putBatchRecords<T>(cacheRecords: TtlCacheRecord<T>[]): Promise<void>;
51
+ /**
52
+ * Adds a value to the left end of a Redis list.
53
+ *
54
+ * @template T - The type of value being enqueued
55
+ * @param {string} queueName - The name of the Redis list
56
+ * @param {T} value - The value to add to the list
57
+ * @returns {Promise<void>} A promise that resolves when the value is enqueued
58
+ */
59
+ enqueueRecord<T>(queueName: string, value: T): Promise<void>;
60
+ /**
61
+ * Adds multiple values to the left end of a Redis list in a single transaction.
62
+ *
63
+ * @template T - The type of values being enqueued
64
+ * @param {string} queueName - The name of the Redis list
65
+ * @param {T[]} values - Array of values to add to the list
66
+ * @returns {Promise<void>} A promise that resolves when all values are enqueued
67
+ */
68
+ enqueueBatchRecords<T>(queueName: string, values: T[]): Promise<void>;
69
+ /**
70
+ * Deletes a record from the Redis cache.
71
+ *
72
+ * @param {string} cacheRecordKey - The key of the record to delete
73
+ * @returns {Promise<void>} A promise that resolves when the record is deleted
74
+ */
75
+ deleteRecord(cacheRecordKey: string): Promise<void>;
76
+ /**
77
+ * Deletes multiple records from the Redis cache in a single transaction.
78
+ *
79
+ * @param {string[]} cacheRecordKeys - Array of keys to delete
80
+ * @returns {Promise<void>} A promise that resolves when all records are deleted
81
+ */
82
+ deleteBatchRecords(cacheRecordKeys: string[]): Promise<void>;
83
+ /**
84
+ * Removes and returns the rightmost element from a Redis list.
85
+ *
86
+ * @template T - The type of value being dequeued
87
+ * @param {string} queueName - The name of the Redis list
88
+ * @returns {Promise<T>} A promise that resolves with the dequeued value
89
+ * @throws {Error} If the queue is empty
90
+ */
91
+ dequeueRecord<T>(queueName: string): Promise<T>;
92
+ /**
93
+ * Removes and returns multiple elements from the right end of a Redis list.
94
+ *
95
+ * @template T - The type of values being dequeued
96
+ * @param {string} queueName - The name of the Redis list
97
+ * @param {number} pageSize - Maximum number of elements to dequeue
98
+ * @returns {Promise<T[]>} A promise that resolves with an array of dequeued values
99
+ */
100
+ dequeueBatchRecords<T>(queueName: string, pageSize: number): Promise<T[]>;
101
+ /**
102
+ * Reads a record from the Redis cache.
103
+ *
104
+ * @template T - The type of value being read
105
+ * @param {string} cacheRecordKey - The key of the record to read
106
+ * @returns {Promise<TtlCacheRecord<T>>} A promise that resolves with the cache record
107
+ * @throws {Error} If the record is not found
108
+ */
109
+ readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>>;
110
+ /**
111
+ * Reads multiple records from the Redis cache.
112
+ *
113
+ * @template T - The type of values being read
114
+ * @param {string[] | string} cacheRecordKeysOrPrefix - Array of keys to read, or a prefix pattern
115
+ * @returns {Promise<TtlCacheRecord<T>[]>} A promise that resolves with an array of cache records
116
+ */
117
+ readBatchRecords<T>(cacheRecordKeysOrPrefix: string[] | string): Promise<TtlCacheRecord<T>[]>;
118
+ /**
119
+ * Lists all keys in the Redis cache that match a pattern prefix.
120
+ *
121
+ * @param {string} pattern_prefix - The prefix pattern to match keys against
122
+ * @returns {Promise<string[]>} A promise that resolves with an array of matching keys
123
+ */
124
+ listKeys(pattern_prefix: string): Promise<string[]>;
125
+ /**
126
+ * Checks if a record exists in the Redis cache.
127
+ *
128
+ * @param {string} cacheRecordKey - The key to check
129
+ * @returns {Promise<boolean>} A promise that resolves with true if the record exists, false otherwise
130
+ */
131
+ peekRecord(cacheRecordKey: string): Promise<boolean>;
132
+ /**
133
+ * Checks if multiple records exist in the Redis cache.
134
+ *
135
+ * @param {string[] | string} cacheRecordKeysOrPrefix - Array of keys to check, or a prefix pattern
136
+ * @returns {Promise<boolean[]>} A promise that resolves with an array of existence booleans
137
+ */
138
+ peekBatchRecords(cacheRecordKeysOrPrefix: string[] | string): Promise<boolean[]>;
139
+ /**
140
+ * Peeks at a record in the Redis cache.
141
+ *
142
+ * @template T - The type of value being peeked at
143
+ * @param {string} queueName - The name of the Redis queue
144
+ * @returns {Promise<T>} A promise that resolves with the peeked value
145
+ */
146
+ peekQueueRecord<T>(queueName: string): Promise<T>;
147
+ /**
148
+ * Peeks at multiple records in the Redis cache.
149
+ *
150
+ * @template T - The type of values being peeked at
151
+ * @param {string} queueName - The name of the Redis queue
152
+ * @param {number} pageSize - The number of records to peek at
153
+ * @returns {Promise<T[]>} A promise that resolves with an array of peeked values
154
+ */
155
+ peekQueueRecords<T>(queueName: string, pageSize: number): Promise<T[]>;
156
+ /**
157
+ * Gracefully disconnects from the Redis server.
158
+ *
159
+ * @returns {Promise<void>} A promise that resolves when the connection is closed
160
+ */
161
+ disconnect(): Promise<void>;
162
+ /**
163
+ * Gets the default Time-To-Live value in milliseconds.
164
+ *
165
+ * @returns {number} The default TTL in milliseconds
166
+ */
167
+ getTtlMilliseconds(): number;
168
+ /**
169
+ * Gets the underlying Redis client instance.
170
+ *
171
+ * @returns {typeof this.client} The Redis client instance
172
+ */
173
+ getClient(): typeof this.client;
174
+ }
175
+
176
+ export { RedisTtlCache };