bun-types 1.2.23 → 1.2.24-canary.20251002T140601

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/redis.d.ts CHANGED
@@ -34,14 +34,7 @@ declare module "bun" {
34
34
  * TLS options
35
35
  * Can be a boolean or an object with TLS options
36
36
  */
37
- tls?:
38
- | boolean
39
- | {
40
- key?: string | Buffer;
41
- cert?: string | Buffer;
42
- ca?: string | Buffer | Array<string | Buffer>;
43
- rejectUnauthorized?: boolean;
44
- };
37
+ tls?: boolean | Bun.TLSOptions;
45
38
 
46
39
  /**
47
40
  * Whether to enable auto-pipelining
@@ -245,6 +238,22 @@ declare module "bun" {
245
238
  */
246
239
  incr(key: RedisClient.KeyLike): Promise<number>;
247
240
 
241
+ /**
242
+ * Increment the integer value of a key by the given amount
243
+ * @param key The key to increment
244
+ * @param increment The amount to increment by
245
+ * @returns Promise that resolves with the new value after incrementing
246
+ */
247
+ incrby(key: RedisClient.KeyLike, increment: number): Promise<number>;
248
+
249
+ /**
250
+ * Increment the float value of a key by the given amount
251
+ * @param key The key to increment
252
+ * @param increment The amount to increment by (can be a float)
253
+ * @returns Promise that resolves with the new value as a string after incrementing
254
+ */
255
+ incrbyfloat(key: RedisClient.KeyLike, increment: number | string): Promise<string>;
256
+
248
257
  /**
249
258
  * Decrement the integer value of a key by one
250
259
  * @param key The key to decrement
@@ -252,6 +261,14 @@ declare module "bun" {
252
261
  */
253
262
  decr(key: RedisClient.KeyLike): Promise<number>;
254
263
 
264
+ /**
265
+ * Decrement the integer value of a key by the given amount
266
+ * @param key The key to decrement
267
+ * @param decrement The amount to decrement by
268
+ * @returns Promise that resolves with the new value after decrementing
269
+ */
270
+ decrby(key: RedisClient.KeyLike, decrement: number): Promise<number>;
271
+
255
272
  /**
256
273
  * Determine if a key exists
257
274
  * @param key The key to check
@@ -268,6 +285,22 @@ declare module "bun" {
268
285
  */
269
286
  expire(key: RedisClient.KeyLike, seconds: number): Promise<number>;
270
287
 
288
+ /**
289
+ * Set the expiration for a key as a Unix timestamp (in seconds)
290
+ * @param key The key to set expiration on
291
+ * @param timestamp Unix timestamp in seconds when the key should expire
292
+ * @returns Promise that resolves with 1 if timeout was set, 0 if key does not exist
293
+ */
294
+ expireat(key: RedisClient.KeyLike, timestamp: number): Promise<number>;
295
+
296
+ /**
297
+ * Set a key's time to live in milliseconds
298
+ * @param key The key to set the expiration for
299
+ * @param milliseconds The number of milliseconds until expiration
300
+ * @returns Promise that resolves with 1 if the timeout was set, 0 if the key does not exist
301
+ */
302
+ pexpire(key: RedisClient.KeyLike, milliseconds: number): Promise<number>;
303
+
271
304
  /**
272
305
  * Get the time to live for a key in seconds
273
306
  * @param key The key to get the TTL for
@@ -276,13 +309,313 @@ declare module "bun" {
276
309
  */
277
310
  ttl(key: RedisClient.KeyLike): Promise<number>;
278
311
 
312
+ /**
313
+ * Set the value of a hash field or multiple fields
314
+ * @param key The hash key
315
+ * @param fields Object/Record with field-value pairs
316
+ * @returns Promise that resolves with the number of fields that were added
317
+ */
318
+ hset(key: RedisClient.KeyLike, fields: Record<string | number, RedisClient.KeyLike | number>): Promise<number>;
319
+
320
+ /**
321
+ * Set the value of a hash field or multiple fields (variadic)
322
+ * @param key The hash key
323
+ * @param field The field name
324
+ * @param value The value to set
325
+ * @param rest Additional field-value pairs
326
+ * @returns Promise that resolves with the number of fields that were added
327
+ */
328
+ hset(
329
+ key: RedisClient.KeyLike,
330
+ field: RedisClient.KeyLike,
331
+ value: RedisClient.KeyLike,
332
+ ...rest: RedisClient.KeyLike[]
333
+ ): Promise<number>;
334
+
335
+ /**
336
+ * Set the value of a hash field, only if the field does not exist
337
+ * @param key The hash key
338
+ * @param field The field to set
339
+ * @param value The value to set
340
+ * @returns Promise that resolves with true if field was set, false if field already exists
341
+ */
342
+ hsetnx(key: RedisClient.KeyLike, field: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<boolean>;
343
+
344
+ /**
345
+ * Get and delete one or more hash fields (Redis 8.0.0+)
346
+ * Syntax: HGETDEL key FIELDS numfields field [field ...]
347
+ * @param key The hash key
348
+ * @param fieldsKeyword Must be the literal string "FIELDS"
349
+ * @param numfields Number of fields to follow
350
+ * @param fields The field names to get and delete
351
+ * @returns Promise that resolves with array of field values (null for non-existent fields)
352
+ * @example redis.hgetdel("mykey", "FIELDS", 2, "field1", "field2")
353
+ */
354
+ hgetdel(
355
+ key: RedisClient.KeyLike,
356
+ fieldsKeyword: "FIELDS",
357
+ numfields: number,
358
+ ...fields: RedisClient.KeyLike[]
359
+ ): Promise<Array<string | null>>;
360
+
361
+ /**
362
+ * Get hash field values with expiration options (Redis 8.0.0+)
363
+ * Syntax: HGETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | PERSIST] FIELDS numfields field [field ...]
364
+ * @example redis.hgetex("mykey", "FIELDS", 1, "field1")
365
+ * @example redis.hgetex("mykey", "EX", 10, "FIELDS", 1, "field1")
366
+ * @example redis.hgetex("mykey", "PX", 5000, "FIELDS", 2, "field1", "field2")
367
+ * @example redis.hgetex("mykey", "PERSIST", "FIELDS", 1, "field1")
368
+ */
369
+ //prettier-ignore
370
+ hgetex(key: RedisClient.KeyLike, fieldsKeyword: "FIELDS", numfields: number, ...fields: RedisClient.KeyLike[]): Promise<Array<string | null>>;
371
+ //prettier-ignore
372
+ hgetex(key: RedisClient.KeyLike, ex: "EX", seconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fields: RedisClient.KeyLike[]): Promise<Array<string | null>>;
373
+ //prettier-ignore
374
+ hgetex(key: RedisClient.KeyLike, px: "PX", milliseconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fields: RedisClient.KeyLike[]): Promise<Array<string | null>>;
375
+ //prettier-ignore
376
+ hgetex(key: RedisClient.KeyLike, exat: "EXAT", unixTimeSeconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fields: RedisClient.KeyLike[]): Promise<Array<string | null>>;
377
+ //prettier-ignore
378
+ hgetex(key: RedisClient.KeyLike, pxat: "PXAT", unixTimeMilliseconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fields: RedisClient.KeyLike[]): Promise<Array<string | null>>;
379
+ //prettier-ignore
380
+ hgetex(key: RedisClient.KeyLike, persist: "PERSIST", fieldsKeyword: "FIELDS", numfields: number, ...fields: RedisClient.KeyLike[]): Promise<Array<string | null>>;
381
+
382
+ /**
383
+ * Set hash fields with expiration options (Redis 8.0.0+)
384
+ * Syntax: HSETEX key [FNX | FXX] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL] FIELDS numfields field value [field value ...]
385
+ * @example redis.hsetex("mykey", "FIELDS", 1, "field1", "value1")
386
+ * @example redis.hsetex("mykey", "EX", 10, "FIELDS", 1, "field1", "value1")
387
+ * @example redis.hsetex("mykey", "FNX", "EX", 10, "FIELDS", 1, "field1", "value1")
388
+ */
389
+ //prettier-ignore
390
+ hsetex(key: RedisClient.KeyLike, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
391
+ //prettier-ignore
392
+ hsetex(key: RedisClient.KeyLike, fnx: "FNX", fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
393
+ //prettier-ignore
394
+ hsetex(key: RedisClient.KeyLike, fxx: "FXX", fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
395
+ //prettier-ignore
396
+ hsetex(key: RedisClient.KeyLike, ex: "EX", seconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
397
+ //prettier-ignore
398
+ hsetex(key: RedisClient.KeyLike, px: "PX", milliseconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
399
+ //prettier-ignore
400
+ hsetex(key: RedisClient.KeyLike, exat: "EXAT", unixTimeSeconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
401
+ //prettier-ignore
402
+ hsetex(key: RedisClient.KeyLike, pxat: "PXAT", unixTimeMilliseconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
403
+ //prettier-ignore
404
+ hsetex(key: RedisClient.KeyLike, keepttl: "KEEPTTL", fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
405
+ //prettier-ignore
406
+ hsetex(key: RedisClient.KeyLike, fnx: "FNX", ex: "EX", seconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
407
+ //prettier-ignore
408
+ hsetex(key: RedisClient.KeyLike, fnx: "FNX", px: "PX", milliseconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
409
+ //prettier-ignore
410
+ hsetex(key: RedisClient.KeyLike, fnx: "FNX", exat: "EXAT", unixTimeSeconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
411
+ //prettier-ignore
412
+ hsetex(key: RedisClient.KeyLike, fnx: "FNX", pxat: "PXAT", unixTimeMilliseconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
413
+ //prettier-ignore
414
+ hsetex(key: RedisClient.KeyLike, fnx: "FNX", keepttl: "KEEPTTL", fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
415
+ //prettier-ignore
416
+ hsetex(key: RedisClient.KeyLike, fxx: "FXX", ex: "EX", seconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
417
+ //prettier-ignore
418
+ hsetex(key: RedisClient.KeyLike, fxx: "FXX", px: "PX", milliseconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
419
+ //prettier-ignore
420
+ hsetex(key: RedisClient.KeyLike, fxx: "FXX", exat: "EXAT", unixTimeSeconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
421
+ //prettier-ignore
422
+ hsetex(key: RedisClient.KeyLike, fxx: "FXX", pxat: "PXAT", unixTimeMilliseconds: number, fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
423
+ //prettier-ignore
424
+ hsetex(key: RedisClient.KeyLike, fxx: "FXX", keepttl: "KEEPTTL", fieldsKeyword: "FIELDS", numfields: number, ...fieldValues: RedisClient.KeyLike[]): Promise<number>;
425
+
426
+ /**
427
+ * Set expiration for hash fields (Redis 7.4+)
428
+ * Syntax: HEXPIRE key seconds [NX | XX | GT | LT] FIELDS numfields field [field ...]
429
+ * @returns Array where each element is: -2 (field doesn't exist), 0 (condition not met), 1 (expiration set), 2 (field deleted)
430
+ * @example redis.hexpire("mykey", 10, "FIELDS", 1, "field1")
431
+ * @example redis.hexpire("mykey", 10, "NX", "FIELDS", 2, "field1", "field2")
432
+ */
433
+ hexpire(
434
+ key: RedisClient.KeyLike,
435
+ seconds: number,
436
+ fieldsKeyword: "FIELDS",
437
+ numfields: number,
438
+ ...fields: RedisClient.KeyLike[]
439
+ ): Promise<number[]>;
440
+ hexpire(
441
+ key: RedisClient.KeyLike,
442
+ seconds: number,
443
+ condition: "NX" | "XX" | "GT" | "LT",
444
+ fieldsKeyword: "FIELDS",
445
+ numfields: number,
446
+ ...fields: RedisClient.KeyLike[]
447
+ ): Promise<number[]>;
448
+
449
+ /**
450
+ * Set expiration for hash fields using Unix timestamp in seconds (Redis 7.4+)
451
+ * Syntax: HEXPIREAT key unix-time-seconds [NX | XX | GT | LT] FIELDS numfields field [field ...]
452
+ * @returns Array where each element is: -2 (field doesn't exist), 0 (condition not met), 1 (expiration set), 2 (field deleted)
453
+ * @example redis.hexpireat("mykey", 1735689600, "FIELDS", 1, "field1")
454
+ */
455
+ hexpireat(
456
+ key: RedisClient.KeyLike,
457
+ unixTimeSeconds: number,
458
+ fieldsKeyword: "FIELDS",
459
+ numfields: number,
460
+ ...fields: RedisClient.KeyLike[]
461
+ ): Promise<number[]>;
462
+ hexpireat(
463
+ key: RedisClient.KeyLike,
464
+ unixTimeSeconds: number,
465
+ condition: "NX" | "XX" | "GT" | "LT",
466
+ fieldsKeyword: "FIELDS",
467
+ numfields: number,
468
+ ...fields: RedisClient.KeyLike[]
469
+ ): Promise<number[]>;
470
+
471
+ /**
472
+ * Get expiration time of hash fields as Unix timestamp in seconds (Redis 7.4+)
473
+ * Syntax: HEXPIRETIME key FIELDS numfields field [field ...]
474
+ * @returns Array where each element is: -2 (field doesn't exist), -1 (no expiration), Unix timestamp in seconds
475
+ * @example redis.hexpiretime("mykey", "FIELDS", 2, "field1", "field2")
476
+ */
477
+ hexpiretime(
478
+ key: RedisClient.KeyLike,
479
+ fieldsKeyword: "FIELDS",
480
+ numfields: number,
481
+ ...fields: RedisClient.KeyLike[]
482
+ ): Promise<number[]>;
483
+
484
+ /**
485
+ * Remove expiration from hash fields (Redis 7.4+)
486
+ * Syntax: HPERSIST key FIELDS numfields field [field ...]
487
+ * @returns Array where each element is: -2 (field doesn't exist), -1 (no expiration), 1 (expiration removed)
488
+ * @example redis.hpersist("mykey", "FIELDS", 1, "field1")
489
+ */
490
+ hpersist(
491
+ key: RedisClient.KeyLike,
492
+ fieldsKeyword: "FIELDS",
493
+ numfields: number,
494
+ ...fields: RedisClient.KeyLike[]
495
+ ): Promise<number[]>;
496
+
497
+ /**
498
+ * Set expiration for hash fields in milliseconds (Redis 7.4+)
499
+ * Syntax: HPEXPIRE key milliseconds [NX | XX | GT | LT] FIELDS numfields field [field ...]
500
+ * @returns Array where each element is: -2 (field doesn't exist), 0 (condition not met), 1 (expiration set), 2 (field deleted)
501
+ * @example redis.hpexpire("mykey", 10000, "FIELDS", 1, "field1")
502
+ */
503
+ hpexpire(
504
+ key: RedisClient.KeyLike,
505
+ milliseconds: number,
506
+ fieldsKeyword: "FIELDS",
507
+ numfields: number,
508
+ ...fields: RedisClient.KeyLike[]
509
+ ): Promise<number[]>;
510
+ hpexpire(
511
+ key: RedisClient.KeyLike,
512
+ milliseconds: number,
513
+ condition: "NX" | "XX" | "GT" | "LT",
514
+ fieldsKeyword: "FIELDS",
515
+ numfields: number,
516
+ ...fields: RedisClient.KeyLike[]
517
+ ): Promise<number[]>;
518
+
519
+ /**
520
+ * Set expiration for hash fields using Unix timestamp in milliseconds (Redis 7.4+)
521
+ * Syntax: HPEXPIREAT key unix-time-milliseconds [NX | XX | GT | LT] FIELDS numfields field [field ...]
522
+ * @returns Array where each element is: -2 (field doesn't exist), 0 (condition not met), 1 (expiration set), 2 (field deleted)
523
+ * @example redis.hpexpireat("mykey", 1735689600000, "FIELDS", 1, "field1")
524
+ */
525
+ hpexpireat(
526
+ key: RedisClient.KeyLike,
527
+ unixTimeMilliseconds: number,
528
+ fieldsKeyword: "FIELDS",
529
+ numfields: number,
530
+ ...fields: RedisClient.KeyLike[]
531
+ ): Promise<number[]>;
532
+ hpexpireat(
533
+ key: RedisClient.KeyLike,
534
+ unixTimeMilliseconds: number,
535
+ condition: "NX" | "XX" | "GT" | "LT",
536
+ fieldsKeyword: "FIELDS",
537
+ numfields: number,
538
+ ...fields: RedisClient.KeyLike[]
539
+ ): Promise<number[]>;
540
+
541
+ /**
542
+ * Get expiration time of hash fields as Unix timestamp in milliseconds (Redis 7.4+)
543
+ * Syntax: HPEXPIRETIME key FIELDS numfields field [field ...]
544
+ * @returns Array where each element is: -2 (field doesn't exist), -1 (no expiration), Unix timestamp in milliseconds
545
+ * @example redis.hpexpiretime("mykey", "FIELDS", 2, "field1", "field2")
546
+ */
547
+ hpexpiretime(
548
+ key: RedisClient.KeyLike,
549
+ fieldsKeyword: "FIELDS",
550
+ numfields: number,
551
+ ...fields: RedisClient.KeyLike[]
552
+ ): Promise<number[]>;
553
+
554
+ /**
555
+ * Get TTL of hash fields in milliseconds (Redis 7.4+)
556
+ * Syntax: HPTTL key FIELDS numfields field [field ...]
557
+ * @returns Array where each element is: -2 (field doesn't exist), -1 (no expiration), TTL in milliseconds
558
+ * @example redis.hpttl("mykey", "FIELDS", 2, "field1", "field2")
559
+ */
560
+ hpttl(
561
+ key: RedisClient.KeyLike,
562
+ fieldsKeyword: "FIELDS",
563
+ numfields: number,
564
+ ...fields: RedisClient.KeyLike[]
565
+ ): Promise<number[]>;
566
+
567
+ /**
568
+ * Get TTL of hash fields in seconds (Redis 7.4+)
569
+ * Syntax: HTTL key FIELDS numfields field [field ...]
570
+ * @returns Array where each element is: -2 (field doesn't exist), -1 (no expiration), TTL in seconds
571
+ * @example redis.httl("mykey", "FIELDS", 2, "field1", "field2")
572
+ */
573
+ httl(
574
+ key: RedisClient.KeyLike,
575
+ fieldsKeyword: "FIELDS",
576
+ numfields: number,
577
+ ...fields: RedisClient.KeyLike[]
578
+ ): Promise<number[]>;
579
+
279
580
  /**
280
581
  * Set multiple hash fields to multiple values
582
+ *
583
+ * @deprecated Use {@link hset} instead. Since Redis 4.0.0, `HSET` supports multiple field-value pairs.
584
+ *
585
+ * @param key The hash key
586
+ * @param fields Object/Record with field-value pairs
587
+ * @returns Promise that resolves with "OK"
588
+ */
589
+ hmset(key: RedisClient.KeyLike, fields: Record<string | number, RedisClient.KeyLike | number>): Promise<"OK">;
590
+
591
+ /**
592
+ * Set multiple hash fields to multiple values (variadic)
593
+ *
594
+ * @deprecated Use {@link hset} instead. Since Redis 4.0.0, `HSET` supports multiple field-value pairs.
595
+ *
596
+ * @param key The hash key
597
+ * @param field The field name
598
+ * @param value The value to set
599
+ * @param rest Additional field-value pairs
600
+ * @returns Promise that resolves with "OK"
601
+ */
602
+ hmset(
603
+ key: RedisClient.KeyLike,
604
+ field: RedisClient.KeyLike,
605
+ value: RedisClient.KeyLike,
606
+ ...rest: RedisClient.KeyLike[]
607
+ ): Promise<"OK">;
608
+
609
+ /**
610
+ * Set multiple hash fields to multiple values (array syntax, backward compat)
611
+ *
612
+ * @deprecated Use {@link hset} instead. Since Redis 4.0.0, `HSET` supports multiple field-value pairs.
613
+ *
281
614
  * @param key The hash key
282
615
  * @param fieldValues An array of alternating field names and values
283
- * @returns Promise that resolves with "OK" on success
616
+ * @returns Promise that resolves with "OK"
284
617
  */
285
- hmset(key: RedisClient.KeyLike, fieldValues: string[]): Promise<string>;
618
+ hmset(key: RedisClient.KeyLike, fieldValues: RedisClient.KeyLike[]): Promise<"OK">;
286
619
 
287
620
  /**
288
621
  * Get the value of a hash field
@@ -292,6 +625,14 @@ declare module "bun" {
292
625
  */
293
626
  hget(key: RedisClient.KeyLike, field: RedisClient.KeyLike): Promise<string | null>;
294
627
 
628
+ /**
629
+ * Get the values of all the given hash fields
630
+ * @param key The hash key
631
+ * @param fields The fields to get
632
+ * @returns Promise that resolves with an array of values
633
+ */
634
+ hmget(key: RedisClient.KeyLike, ...fields: string[]): Promise<Array<string | null>>;
635
+
295
636
  /**
296
637
  * Get the values of all the given hash fields
297
638
  * @param key The hash key
@@ -300,6 +641,104 @@ declare module "bun" {
300
641
  */
301
642
  hmget(key: RedisClient.KeyLike, fields: string[]): Promise<Array<string | null>>;
302
643
 
644
+ /**
645
+ * Delete one or more hash fields
646
+ * @param key The hash key
647
+ * @param field The field to delete
648
+ * @param rest Additional fields to delete
649
+ * @returns Promise that resolves with the number of fields that were removed
650
+ */
651
+ hdel(key: RedisClient.KeyLike, field: RedisClient.KeyLike, ...rest: RedisClient.KeyLike[]): Promise<number>;
652
+
653
+ /**
654
+ * Determine if a hash field exists
655
+ * @param key The hash key
656
+ * @param field The field to check
657
+ * @returns Promise that resolves with true if the field exists, false otherwise
658
+ */
659
+ hexists(key: RedisClient.KeyLike, field: RedisClient.KeyLike): Promise<boolean>;
660
+
661
+ /**
662
+ * Get one or multiple random fields from a hash
663
+ * @param key The hash key
664
+ * @returns Promise that resolves with a random field name, or null if the hash doesn't exist
665
+ */
666
+ hrandfield(key: RedisClient.KeyLike): Promise<string | null>;
667
+
668
+ /**
669
+ * Get one or multiple random fields from a hash
670
+ * @param key The hash key
671
+ * @param count The number of fields to return (positive for unique fields, negative for potentially duplicate fields)
672
+ * @returns Promise that resolves with an array of random field names
673
+ */
674
+ hrandfield(key: RedisClient.KeyLike, count: number): Promise<string[]>;
675
+
676
+ /**
677
+ * Get one or multiple random fields with values from a hash
678
+ * @param key The hash key
679
+ * @param count The number of fields to return
680
+ * @param withValues Literal "WITHVALUES" to include values
681
+ * @returns Promise that resolves with an array of alternating field names and values
682
+ */
683
+ hrandfield(key: RedisClient.KeyLike, count: number, withValues: "WITHVALUES"): Promise<[string, string][]>;
684
+
685
+ /**
686
+ * Incrementally iterate hash fields and values
687
+ * @param key The hash key
688
+ * @param cursor The cursor value (0 to start iteration)
689
+ * @returns Promise that resolves with [next_cursor, [field1, value1, field2, value2, ...]]
690
+ */
691
+ hscan(key: RedisClient.KeyLike, cursor: number | string): Promise<[string, string[]]>;
692
+
693
+ /**
694
+ * Incrementally iterate hash fields and values with pattern matching
695
+ * @param key The hash key
696
+ * @param cursor The cursor value (0 to start iteration)
697
+ * @param match Literal "MATCH"
698
+ * @param pattern Pattern to match field names against
699
+ * @returns Promise that resolves with [next_cursor, [field1, value1, field2, value2, ...]]
700
+ */
701
+ hscan(
702
+ key: RedisClient.KeyLike,
703
+ cursor: number | string,
704
+ match: "MATCH",
705
+ pattern: string,
706
+ ): Promise<[string, string[]]>;
707
+
708
+ /**
709
+ * Incrementally iterate hash fields and values with count limit
710
+ * @param key The hash key
711
+ * @param cursor The cursor value (0 to start iteration)
712
+ * @param count Literal "COUNT"
713
+ * @param limit Maximum number of fields to return per call
714
+ * @returns Promise that resolves with [next_cursor, [field1, value1, field2, value2, ...]]
715
+ */
716
+ hscan(
717
+ key: RedisClient.KeyLike,
718
+ cursor: number | string,
719
+ count: "COUNT",
720
+ limit: number,
721
+ ): Promise<[string, string[]]>;
722
+
723
+ /**
724
+ * Incrementally iterate hash fields and values with pattern and count
725
+ * @param key The hash key
726
+ * @param cursor The cursor value (0 to start iteration)
727
+ * @param match Literal "MATCH"
728
+ * @param pattern Pattern to match field names against
729
+ * @param count Literal "COUNT"
730
+ * @param limit Maximum number of fields to return per call
731
+ * @returns Promise that resolves with [next_cursor, [field1, value1, field2, value2, ...]]
732
+ */
733
+ hscan(
734
+ key: RedisClient.KeyLike,
735
+ cursor: number | string,
736
+ match: "MATCH",
737
+ pattern: string,
738
+ count: "COUNT",
739
+ limit: number,
740
+ ): Promise<[string, string[]]>;
741
+
303
742
  /**
304
743
  * Check if a value is a member of a set
305
744
  * @param key The set key
@@ -310,22 +749,29 @@ declare module "bun" {
310
749
  sismember(key: RedisClient.KeyLike, member: string): Promise<boolean>;
311
750
 
312
751
  /**
313
- * Add a member to a set
752
+ * Add one or more members to a set
314
753
  * @param key The set key
315
- * @param member The member to add
316
- * @returns Promise that resolves with 1 if the member was added, 0 if it
317
- * already existed
754
+ * @param members The members to add
755
+ * @returns Promise that resolves with the number of members added
318
756
  */
319
- sadd(key: RedisClient.KeyLike, member: string): Promise<number>;
757
+ sadd(key: RedisClient.KeyLike, ...members: string[]): Promise<number>;
320
758
 
321
759
  /**
322
- * Remove a member from a set
760
+ * Remove one or more members from a set
323
761
  * @param key The set key
324
- * @param member The member to remove
325
- * @returns Promise that resolves with 1 if the member was removed, 0 if it
326
- * didn't exist
762
+ * @param members The members to remove
763
+ * @returns Promise that resolves with the number of members removed
327
764
  */
328
- srem(key: RedisClient.KeyLike, member: string): Promise<number>;
765
+ srem(key: RedisClient.KeyLike, ...members: string[]): Promise<number>;
766
+
767
+ /**
768
+ * Move a member from one set to another
769
+ * @param source The source set key
770
+ * @param destination The destination set key
771
+ * @param member The member to move
772
+ * @returns Promise that resolves with true if the element was moved, false if it wasn't a member of source
773
+ */
774
+ smove(source: RedisClient.KeyLike, destination: RedisClient.KeyLike, member: string): Promise<boolean>;
329
775
 
330
776
  /**
331
777
  * Get all the members in a set
@@ -342,6 +788,14 @@ declare module "bun" {
342
788
  */
343
789
  srandmember(key: RedisClient.KeyLike): Promise<string | null>;
344
790
 
791
+ /**
792
+ * Get count random members from a set
793
+ * @param key The set key
794
+ * @returns Promise that resolves with an array of up to count random members, or null if the set
795
+ * doesn't exist
796
+ */
797
+ srandmember(key: RedisClient.KeyLike, count: number): Promise<string[] | null>;
798
+
345
799
  /**
346
800
  * Remove and return a random member from a set
347
801
  * @param key The set key
@@ -350,6 +804,57 @@ declare module "bun" {
350
804
  */
351
805
  spop(key: RedisClient.KeyLike): Promise<string | null>;
352
806
 
807
+ /**
808
+ * Remove and return count members from the set
809
+ * @param key The set key
810
+ * @returns Promise that resolves with the removed members, or null if the
811
+ * set is empty
812
+ */
813
+ spop(key: RedisClient.KeyLike, count: number): Promise<string[] | null>;
814
+
815
+ /**
816
+ * Post a message to a shard channel
817
+ * @param channel The shard channel name
818
+ * @param message The message to publish
819
+ * @returns Promise that resolves with the number of clients that received the message
820
+ */
821
+ spublish(channel: RedisClient.KeyLike, message: string): Promise<number>;
822
+
823
+ /**
824
+ * Store the difference of multiple sets in a key
825
+ * @param destination The destination key to store the result
826
+ * @param key The first set key
827
+ * @param keys Additional set keys to subtract from the first set
828
+ * @returns Promise that resolves with the number of elements in the resulting set
829
+ */
830
+ sdiffstore(
831
+ destination: RedisClient.KeyLike,
832
+ key: RedisClient.KeyLike,
833
+ ...keys: RedisClient.KeyLike[]
834
+ ): Promise<number>;
835
+
836
+ /**
837
+ * Check if multiple members are members of a set
838
+ * @param key The set key
839
+ * @param member The first member to check
840
+ * @param members Additional members to check
841
+ * @returns Promise that resolves with an array of 1s and 0s indicating membership
842
+ */
843
+ smismember(
844
+ key: RedisClient.KeyLike,
845
+ member: RedisClient.KeyLike,
846
+ ...members: RedisClient.KeyLike[]
847
+ ): Promise<number[]>;
848
+
849
+ /**
850
+ * Incrementally iterate over a set
851
+ * @param key The set key
852
+ * @param cursor The cursor value
853
+ * @param args Additional SSCAN options (MATCH pattern, COUNT hint)
854
+ * @returns Promise that resolves with a tuple [cursor, members[]]
855
+ */
856
+ sscan(key: RedisClient.KeyLike, cursor: number | string, ...args: (string | number)[]): Promise<[string, string[]]>;
857
+
353
858
  /**
354
859
  * Increment the integer value of a hash field by the given number
355
860
  * @param key The hash key
@@ -371,9 +876,9 @@ declare module "bun" {
371
876
  /**
372
877
  * Get all the fields and values in a hash
373
878
  * @param key The hash key
374
- * @returns Promise that resolves with an object containing all fields and values
879
+ * @returns Promise that resolves with an object containing all fields and values, or empty object if key does not exist
375
880
  */
376
- hgetall(key: RedisClient.KeyLike): Promise<Record<string, string> | null>;
881
+ hgetall(key: RedisClient.KeyLike): Promise<Record<string, string>>;
377
882
 
378
883
  /**
379
884
  * Get all field names in a hash
@@ -389,6 +894,14 @@ declare module "bun" {
389
894
  */
390
895
  hlen(key: RedisClient.KeyLike): Promise<number>;
391
896
 
897
+ /**
898
+ * Get the string length of the value stored in a hash field
899
+ * @param key The hash key
900
+ * @param field The field name
901
+ * @returns Promise that resolves with the length of the string value, or 0 if the field doesn't exist
902
+ */
903
+ hstrlen(key: RedisClient.KeyLike, field: string): Promise<number>;
904
+
392
905
  /**
393
906
  * Get all values in a hash
394
907
  * @param key The hash key
@@ -404,67 +917,590 @@ declare module "bun" {
404
917
  keys(pattern: string): Promise<string[]>;
405
918
 
406
919
  /**
407
- * Get the length of a list
408
- * @param key The list key
409
- * @returns Promise that resolves with the length of the list
920
+ * Blocking pop from head of one or more lists
921
+ *
922
+ * Blocks until an element is available in one of the lists or the timeout expires.
923
+ * Checks keys in order and pops from the first non-empty list.
924
+ *
925
+ * @param args Keys followed by timeout in seconds (can be fractional, 0 = block indefinitely)
926
+ * @returns Promise that resolves with [key, element] or null on timeout
927
+ *
928
+ * @example
929
+ * ```ts
930
+ * // Block for up to 1 second
931
+ * const result = await redis.blpop("mylist", 1.0);
932
+ * if (result) {
933
+ * const [key, element] = result;
934
+ * console.log(`Popped ${element} from ${key}`);
935
+ * }
936
+ *
937
+ * // Block indefinitely (timeout = 0)
938
+ * const result2 = await redis.blpop("list1", "list2", 0);
939
+ * ```
410
940
  */
411
- llen(key: RedisClient.KeyLike): Promise<number>;
941
+ blpop(...args: (RedisClient.KeyLike | number)[]): Promise<[string, string] | null>;
412
942
 
413
943
  /**
414
- * Remove and get the first element in a list
415
- * @param key The list key
416
- * @returns Promise that resolves with the first element, or null if the
417
- * list is empty
944
+ * Blocking pop from tail of one or more lists
945
+ *
946
+ * Blocks until an element is available in one of the lists or the timeout expires.
947
+ * Checks keys in order and pops from the first non-empty list.
948
+ *
949
+ * @param args Keys followed by timeout in seconds (can be fractional, 0 = block indefinitely)
950
+ * @returns Promise that resolves with [key, element] or null on timeout
951
+ *
952
+ * @example
953
+ * ```ts
954
+ * // Block for up to 1 second
955
+ * const result = await redis.brpop("mylist", 1.0);
956
+ * if (result) {
957
+ * const [key, element] = result;
958
+ * console.log(`Popped ${element} from ${key}`);
959
+ * }
960
+ *
961
+ * // Block indefinitely (timeout = 0)
962
+ * const result2 = await redis.brpop("list1", "list2", 0);
963
+ * ```
418
964
  */
419
- lpop(key: RedisClient.KeyLike): Promise<string | null>;
965
+ brpop(...args: (RedisClient.KeyLike | number)[]): Promise<[string, string] | null>;
420
966
 
421
967
  /**
422
- * Remove the expiration from a key
423
- * @param key The key to persist
424
- * @returns Promise that resolves with 1 if the timeout was removed, 0 if
425
- * the key doesn't exist or has no timeout
968
+ * Blocking move from one list to another
969
+ *
970
+ * Atomically moves an element from source to destination list, blocking until an element is available
971
+ * or the timeout expires. Allows specifying which end to pop from (LEFT/RIGHT) and which end to push to (LEFT/RIGHT).
972
+ *
973
+ * @param source Source list key
974
+ * @param destination Destination list key
975
+ * @param from Direction to pop from source: "LEFT" or "RIGHT"
976
+ * @param to Direction to push to destination: "LEFT" or "RIGHT"
977
+ * @param timeout Timeout in seconds (can be fractional, 0 = block indefinitely)
978
+ * @returns Promise that resolves with the moved element or null on timeout
979
+ *
980
+ * @example
981
+ * ```ts
982
+ * // Move from right of source to left of destination (like BRPOPLPUSH)
983
+ * const element = await redis.blmove("mylist", "otherlist", "RIGHT", "LEFT", 1.0);
984
+ * if (element) {
985
+ * console.log(`Moved element: ${element}`);
986
+ * }
987
+ *
988
+ * // Move from left to left
989
+ * await redis.blmove("list1", "list2", "LEFT", "LEFT", 0.5);
990
+ * ```
426
991
  */
427
- persist(key: RedisClient.KeyLike): Promise<number>;
992
+ blmove(
993
+ source: RedisClient.KeyLike,
994
+ destination: RedisClient.KeyLike,
995
+ from: "LEFT" | "RIGHT",
996
+ to: "LEFT" | "RIGHT",
997
+ timeout: number,
998
+ ): Promise<string | null>;
428
999
 
429
1000
  /**
430
- * Get the expiration time of a key as a UNIX timestamp in milliseconds
431
- * @param key The key to check
432
- * @returns Promise that resolves with the timestamp, or -1 if the key has
433
- * no expiration, or -2 if the key doesn't exist
1001
+ * Blocking pop multiple elements from lists
1002
+ *
1003
+ * Blocks until an element is available from one of the specified lists or the timeout expires.
1004
+ * Can pop from the LEFT or RIGHT end and optionally pop multiple elements at once using COUNT.
1005
+ *
1006
+ * @param timeout Timeout in seconds (can be fractional, 0 = block indefinitely)
1007
+ * @param numkeys Number of keys that follow
1008
+ * @param args Keys, direction ("LEFT" or "RIGHT"), and optional COUNT modifier
1009
+ * @returns Promise that resolves with [key, [elements]] or null on timeout
1010
+ *
1011
+ * @example
1012
+ * ```ts
1013
+ * // Pop from left end of first available list, wait 1 second
1014
+ * const result = await redis.blmpop(1.0, 2, "list1", "list2", "LEFT");
1015
+ * if (result) {
1016
+ * const [key, elements] = result;
1017
+ * console.log(`Popped from ${key}: ${elements.join(", ")}`);
1018
+ * }
1019
+ *
1020
+ * // Pop 3 elements from right end
1021
+ * const result2 = await redis.blmpop(0.5, 1, "mylist", "RIGHT", "COUNT", 3);
1022
+ * // Returns: ["mylist", ["elem1", "elem2", "elem3"]] or null if timeout
1023
+ * ```
434
1024
  */
435
- pexpiretime(key: RedisClient.KeyLike): Promise<number>;
1025
+ blmpop(timeout: number, numkeys: number, ...args: (string | number)[]): Promise<[string, string[]] | null>;
436
1026
 
437
1027
  /**
438
- * Get the time to live for a key in milliseconds
439
- * @param key The key to check
440
- * @returns Promise that resolves with the TTL in milliseconds, or -1 if the
441
- * key has no expiration, or -2 if the key doesn't exist
1028
+ * Blocking right pop from source and left push to destination
1029
+ *
1030
+ * Atomically pops an element from the tail of source list and pushes it to the head of destination list,
1031
+ * blocking until an element is available or the timeout expires. This is the blocking version of RPOPLPUSH.
1032
+ *
1033
+ * @param source Source list key
1034
+ * @param destination Destination list key
1035
+ * @param timeout Timeout in seconds (can be fractional, 0 = block indefinitely)
1036
+ * @returns Promise that resolves with the moved element or null on timeout
1037
+ *
1038
+ * @example
1039
+ * ```ts
1040
+ * // Block for up to 1 second
1041
+ * const element = await redis.brpoplpush("tasks", "processing", 1.0);
1042
+ * if (element) {
1043
+ * console.log(`Processing task: ${element}`);
1044
+ * } else {
1045
+ * console.log("No tasks available");
1046
+ * }
1047
+ *
1048
+ * // Block indefinitely (timeout = 0)
1049
+ * const task = await redis.brpoplpush("queue", "active", 0);
1050
+ * ```
442
1051
  */
443
- pttl(key: RedisClient.KeyLike): Promise<number>;
1052
+ brpoplpush(source: RedisClient.KeyLike, destination: RedisClient.KeyLike, timeout: number): Promise<string | null>;
444
1053
 
445
1054
  /**
446
- * Remove and get the last element in a list
1055
+ * Get element at index from a list
447
1056
  * @param key The list key
448
- * @returns Promise that resolves with the last element, or null if the list is empty
1057
+ * @param index Zero-based index (negative indexes count from the end, -1 is last element)
1058
+ * @returns Promise that resolves with the element at index, or null if index is out of range
1059
+ *
1060
+ * @example
1061
+ * ```ts
1062
+ * await redis.lpush("mylist", "three", "two", "one");
1063
+ * console.log(await redis.lindex("mylist", 0)); // "one"
1064
+ * console.log(await redis.lindex("mylist", -1)); // "three"
1065
+ * console.log(await redis.lindex("mylist", 5)); // null
1066
+ * ```
449
1067
  */
450
- rpop(key: RedisClient.KeyLike): Promise<string | null>;
1068
+ lindex(key: RedisClient.KeyLike, index: number): Promise<string | null>;
451
1069
 
452
1070
  /**
453
- * Get the number of members in a set
454
- * @param key The set key
455
- * @returns Promise that resolves with the cardinality (number of elements)
456
- * of the set
1071
+ * Get the length of a list
1072
+ * @param key The list key
1073
+ * @returns Promise that resolves with the length of the list
457
1074
  */
458
- scard(key: RedisClient.KeyLike): Promise<number>;
1075
+ llen(key: RedisClient.KeyLike): Promise<number>;
459
1076
 
460
1077
  /**
461
- * Get the length of the value stored in a key
462
- * @param key The key to check
463
- * @returns Promise that resolves with the length of the string value, or 0
464
- * if the key doesn't exist
465
- */
466
- strlen(key: RedisClient.KeyLike): Promise<number>;
467
-
1078
+ * Atomically pop an element from a source list and push it to a destination list
1079
+ *
1080
+ * Pops an element from the source list (from LEFT or RIGHT) and pushes it
1081
+ * to the destination list (to LEFT or RIGHT).
1082
+ *
1083
+ * @param source The source list key
1084
+ * @param destination The destination list key
1085
+ * @param from Direction to pop from source: "LEFT" (head) or "RIGHT" (tail)
1086
+ * @param to Direction to push to destination: "LEFT" (head) or "RIGHT" (tail)
1087
+ * @returns Promise that resolves with the element moved, or null if the source list is empty
1088
+ *
1089
+ * @example
1090
+ * ```ts
1091
+ * await redis.lpush("source", "a", "b", "c");
1092
+ * const result1 = await redis.lmove("source", "dest", "LEFT", "RIGHT");
1093
+ * // result1: "c" (popped from head of source, pushed to tail of dest)
1094
+ *
1095
+ * const result2 = await redis.lmove("source", "dest", "RIGHT", "LEFT");
1096
+ * // result2: "a" (popped from tail of source, pushed to head of dest)
1097
+ * ```
1098
+ */
1099
+ lmove(
1100
+ source: RedisClient.KeyLike,
1101
+ destination: RedisClient.KeyLike,
1102
+ from: "LEFT" | "RIGHT",
1103
+ to: "LEFT" | "RIGHT",
1104
+ ): Promise<string | null>;
1105
+
1106
+ /**
1107
+ * Remove and get the first element in a list
1108
+ * @param key The list key
1109
+ * @returns Promise that resolves with the first element, or null if the list is empty
1110
+ */
1111
+ lpop(key: RedisClient.KeyLike): Promise<string | null>;
1112
+
1113
+ /**
1114
+ * Remove and get the first count elements in a list
1115
+ * @param key The list key
1116
+ * @returns Promise that resolves with a list of elements, or null if the list doesn't exist
1117
+ */
1118
+ lpop(key: RedisClient.KeyLike, count: number): Promise<string[] | null>;
1119
+
1120
+ /**
1121
+ * Find the position(s) of an element in a list
1122
+ *
1123
+ * Returns the index of matching elements inside a Redis list.
1124
+ * By default, returns the index of the first match. Use RANK to find the nth occurrence,
1125
+ * COUNT to get multiple positions, and MAXLEN to limit the search.
1126
+ *
1127
+ * @param key The list key
1128
+ * @param element The element to search for
1129
+ * @param options Optional arguments: "RANK", rank, "COUNT", num, "MAXLEN", len
1130
+ * @returns Promise that resolves with the index (number), an array of indices (number[]),
1131
+ * or null if element is not found. Returns array when COUNT option is used.
1132
+ *
1133
+ * @example
1134
+ * ```ts
1135
+ * await redis.lpush("mylist", "a", "b", "c", "b", "d");
1136
+ * const pos1 = await redis.lpos("mylist", "b");
1137
+ * // pos1: 1 (first occurrence of "b")
1138
+ *
1139
+ * const pos2 = await redis.lpos("mylist", "b", "RANK", 2);
1140
+ * // pos2: 3 (second occurrence of "b")
1141
+ *
1142
+ * const positions = await redis.lpos("mylist", "b", "COUNT", 0);
1143
+ * // positions: [1, 3] (all occurrences of "b")
1144
+ *
1145
+ * const pos3 = await redis.lpos("mylist", "x");
1146
+ * // pos3: null (element not found)
1147
+ * ```
1148
+ */
1149
+ lpos(
1150
+ key: RedisClient.KeyLike,
1151
+ element: RedisClient.KeyLike,
1152
+ ...options: (string | number)[]
1153
+ ): Promise<number | number[] | null>;
1154
+
1155
+ /**
1156
+ * Pop one or more elements from one or more lists
1157
+ *
1158
+ * Pops elements from the first non-empty list in the specified order (LEFT = from head, RIGHT = from tail).
1159
+ * Optionally specify COUNT to pop multiple elements at once.
1160
+ *
1161
+ * @param numkeys The number of keys that follow
1162
+ * @param args Keys followed by LEFT or RIGHT, optionally followed by "COUNT" and count value
1163
+ * @returns Promise that resolves with [key, [elements]] or null if all lists are empty
1164
+ *
1165
+ * @example
1166
+ * ```ts
1167
+ * await redis.lpush("list1", "a", "b", "c");
1168
+ * const result1 = await redis.lmpop(1, "list1", "LEFT");
1169
+ * // result1: ["list1", ["c"]]
1170
+ *
1171
+ * const result2 = await redis.lmpop(1, "list1", "RIGHT", "COUNT", 2);
1172
+ * // result2: ["list1", ["a", "b"]]
1173
+ *
1174
+ * const result3 = await redis.lmpop(2, "emptylist", "list1", "LEFT");
1175
+ * // result3: null (if both lists are empty)
1176
+ * ```
1177
+ */
1178
+ lmpop(numkeys: number, ...args: (string | number)[]): Promise<[string, string[]] | null>;
1179
+
1180
+ /**
1181
+ * Get a range of elements from a list
1182
+ * @param key The list key
1183
+ * @param start Zero-based start index (negative indexes count from the end)
1184
+ * @param stop Zero-based stop index (negative indexes count from the end)
1185
+ * @returns Promise that resolves with array of elements in the specified range
1186
+ *
1187
+ * @example
1188
+ * ```ts
1189
+ * await redis.lpush("mylist", "three", "two", "one");
1190
+ * console.log(await redis.lrange("mylist", 0, -1)); // ["one", "two", "three"]
1191
+ * console.log(await redis.lrange("mylist", 0, 1)); // ["one", "two"]
1192
+ * console.log(await redis.lrange("mylist", -2, -1)); // ["two", "three"]
1193
+ * ```
1194
+ */
1195
+ lrange(key: RedisClient.KeyLike, start: number, stop: number): Promise<string[]>;
1196
+
1197
+ /**
1198
+ * Set element at index in a list
1199
+ * @param key The list key
1200
+ * @param index Zero-based index (negative indexes count from the end)
1201
+ * @param element The value to set
1202
+ * @returns Promise that resolves with "OK" on success
1203
+ *
1204
+ * @example
1205
+ * ```ts
1206
+ * await redis.lpush("mylist", "three", "two", "one");
1207
+ * await redis.lset("mylist", 0, "zero");
1208
+ * console.log(await redis.lrange("mylist", 0, -1)); // ["zero", "two", "three"]
1209
+ * await redis.lset("mylist", -1, "last");
1210
+ * console.log(await redis.lrange("mylist", 0, -1)); // ["zero", "two", "last"]
1211
+ * ```
1212
+ */
1213
+ lset(key: RedisClient.KeyLike, index: number, element: RedisClient.KeyLike): Promise<string>;
1214
+
1215
+ /**
1216
+ * Remove the expiration from a key
1217
+ * @param key The key to persist
1218
+ * @returns Promise that resolves with 1 if the timeout was removed, 0 if
1219
+ * the key doesn't exist or has no timeout
1220
+ */
1221
+ persist(key: RedisClient.KeyLike): Promise<number>;
1222
+
1223
+ /**
1224
+ * Set the expiration for a key as a Unix timestamp in milliseconds
1225
+ * @param key The key to set expiration on
1226
+ * @param millisecondsTimestamp Unix timestamp in milliseconds when the key should expire
1227
+ * @returns Promise that resolves with 1 if timeout was set, 0 if key does not exist
1228
+ */
1229
+ pexpireat(key: RedisClient.KeyLike, millisecondsTimestamp: number): Promise<number>;
1230
+
1231
+ /**
1232
+ * Get the expiration time of a key as a UNIX timestamp in milliseconds
1233
+ * @param key The key to check
1234
+ * @returns Promise that resolves with the timestamp, or -1 if the key has
1235
+ * no expiration, or -2 if the key doesn't exist
1236
+ */
1237
+ pexpiretime(key: RedisClient.KeyLike): Promise<number>;
1238
+
1239
+ /**
1240
+ * Get the time to live for a key in milliseconds
1241
+ * @param key The key to check
1242
+ * @returns Promise that resolves with the TTL in milliseconds, or -1 if the
1243
+ * key has no expiration, or -2 if the key doesn't exist
1244
+ */
1245
+ pttl(key: RedisClient.KeyLike): Promise<number>;
1246
+
1247
+ /**
1248
+ * Return a random key from the keyspace
1249
+ *
1250
+ * Returns a random key from the currently selected database.
1251
+ *
1252
+ * @returns Promise that resolves with a random key name, or null if the
1253
+ * database is empty
1254
+ *
1255
+ * @example
1256
+ * ```ts
1257
+ * await redis.set("key1", "value1");
1258
+ * await redis.set("key2", "value2");
1259
+ * await redis.set("key3", "value3");
1260
+ * const randomKey = await redis.randomkey();
1261
+ * console.log(randomKey); // One of: "key1", "key2", or "key3"
1262
+ * ```
1263
+ */
1264
+ randomkey(): Promise<string | null>;
1265
+
1266
+ /**
1267
+ * Remove and get the last element in a list
1268
+ * @param key The list key
1269
+ * @returns Promise that resolves with the last element, or null if the list is empty
1270
+ */
1271
+ rpop(key: RedisClient.KeyLike): Promise<string | null>;
1272
+
1273
+ /**
1274
+ * Remove and get the last element in a list
1275
+ * @param key The list key
1276
+ * @returns Promise that resolves with the last element, or null if the list is empty
1277
+ */
1278
+ rpop(key: RedisClient.KeyLike, count: number): Promise<string[]>;
1279
+
1280
+ /**
1281
+ * Atomically pop the last element from a source list and push it to the head of a destination list
1282
+ *
1283
+ * This is equivalent to LMOVE with "RIGHT" "LEFT". It's an atomic operation that removes
1284
+ * the last element (tail) from the source list and pushes it to the head of the destination list.
1285
+ *
1286
+ * @param source The source list key
1287
+ * @param destination The destination list key
1288
+ * @returns Promise that resolves with the element moved, or null if the source list is empty
1289
+ *
1290
+ * @example
1291
+ * ```ts
1292
+ * await redis.lpush("source", "a", "b", "c");
1293
+ * // source: ["c", "b", "a"]
1294
+ *
1295
+ * const result = await redis.rpoplpush("source", "dest");
1296
+ * // result: "a" (removed from tail of source, added to head of dest)
1297
+ * // source: ["c", "b"]
1298
+ * // dest: ["a"]
1299
+ * ```
1300
+ */
1301
+ rpoplpush(source: RedisClient.KeyLike, destination: RedisClient.KeyLike): Promise<string | null>;
1302
+
1303
+ /**
1304
+ * Incrementally iterate the keyspace
1305
+ *
1306
+ * The SCAN command is used to incrementally iterate over a collection of
1307
+ * elements. SCAN iterates the set of keys in the currently selected Redis
1308
+ * database.
1309
+ *
1310
+ * SCAN is a cursor based iterator. This means that at every call of the
1311
+ * command, the server returns an updated cursor that the user needs to use
1312
+ * as the cursor argument in the next call.
1313
+ *
1314
+ * An iteration starts when the cursor is set to "0", and terminates when
1315
+ * the cursor returned by the server is "0".
1316
+ *
1317
+ * @param cursor The cursor value (use "0" to start a new iteration)
1318
+ * @returns Promise that resolves with a tuple [cursor, keys[]] where cursor
1319
+ * is the next cursor to use (or "0" if iteration is complete) and keys is
1320
+ * an array of matching keys
1321
+ *
1322
+ * @example
1323
+ * ```ts
1324
+ * // Basic scan - iterate all keys
1325
+ * let cursor = "0";
1326
+ * const allKeys: string[] = [];
1327
+ * do {
1328
+ * const [nextCursor, keys] = await redis.scan(cursor);
1329
+ * allKeys.push(...keys);
1330
+ * cursor = nextCursor;
1331
+ * } while (cursor !== "0");
1332
+ * ```
1333
+ *
1334
+ * @example
1335
+ * ```ts
1336
+ * // Scan with MATCH pattern
1337
+ * const [cursor, keys] = await redis.scan("0", "MATCH", "user:*");
1338
+ * ```
1339
+ *
1340
+ * @example
1341
+ * ```ts
1342
+ * // Scan with COUNT hint
1343
+ * const [cursor, keys] = await redis.scan("0", "COUNT", "100");
1344
+ * ```
1345
+ */
1346
+ scan(cursor: string | number): Promise<[string, string[]]>;
1347
+
1348
+ /**
1349
+ * Incrementally iterate the keyspace with a pattern match
1350
+ *
1351
+ * @param cursor The cursor value (use "0" to start a new iteration)
1352
+ * @param match The "MATCH" keyword
1353
+ * @param pattern The pattern to match (supports glob-style patterns like "user:*")
1354
+ * @returns Promise that resolves with a tuple [cursor, keys[]]
1355
+ */
1356
+ scan(cursor: string | number, match: "MATCH", pattern: string): Promise<[string, string[]]>;
1357
+
1358
+ /**
1359
+ * Incrementally iterate the keyspace with a count hint
1360
+ *
1361
+ * @param cursor The cursor value (use "0" to start a new iteration)
1362
+ * @param count The "COUNT" keyword
1363
+ * @param hint The number of elements to return per call (hint only, not exact)
1364
+ * @returns Promise that resolves with a tuple [cursor, keys[]]
1365
+ */
1366
+ scan(cursor: string | number, count: "COUNT", hint: number): Promise<[string, string[]]>;
1367
+
1368
+ /**
1369
+ * Incrementally iterate the keyspace with pattern match and count hint
1370
+ *
1371
+ * @param cursor The cursor value (use "0" to start a new iteration)
1372
+ * @param match The "MATCH" keyword
1373
+ * @param pattern The pattern to match
1374
+ * @param count The "COUNT" keyword
1375
+ * @param hint The number of elements to return per call
1376
+ * @returns Promise that resolves with a tuple [cursor, keys[]]
1377
+ */
1378
+ scan(
1379
+ cursor: string | number,
1380
+ match: "MATCH",
1381
+ pattern: string,
1382
+ count: "COUNT",
1383
+ hint: number,
1384
+ ): Promise<[string, string[]]>;
1385
+
1386
+ /**
1387
+ * Incrementally iterate the keyspace with options
1388
+ *
1389
+ * @param cursor The cursor value
1390
+ * @param options Additional SCAN options (MATCH pattern, COUNT hint, etc.)
1391
+ * @returns Promise that resolves with a tuple [cursor, keys[]]
1392
+ */
1393
+ scan(cursor: string | number, ...options: (string | number)[]): Promise<[string, string[]]>;
1394
+
1395
+ /**
1396
+ * Get the number of members in a set
1397
+ * @param key The set key
1398
+ * @returns Promise that resolves with the cardinality (number of elements)
1399
+ * of the set
1400
+ */
1401
+ scard(key: RedisClient.KeyLike): Promise<number>;
1402
+
1403
+ /**
1404
+ * Get the difference of multiple sets
1405
+ * @param key The first set key
1406
+ * @param keys Additional set keys to subtract from the first set
1407
+ * @returns Promise that resolves with an array of members in the difference
1408
+ */
1409
+ sdiff(key: RedisClient.KeyLike, ...keys: RedisClient.KeyLike[]): Promise<string[]>;
1410
+
1411
+ /**
1412
+ * Get the intersection of multiple sets
1413
+ * @param key The first set key
1414
+ * @param keys Additional set keys to intersect
1415
+ * @returns Promise that resolves with an array of members in the intersection
1416
+ */
1417
+ sinter(key: RedisClient.KeyLike, ...keys: RedisClient.KeyLike[]): Promise<string[]>;
1418
+
1419
+ /**
1420
+ * Store the intersection of multiple sets in a key
1421
+ * @param destination The destination key to store the result
1422
+ * @param key The first set key
1423
+ * @param keys Additional set keys to intersect
1424
+ * @returns Promise that resolves with the number of elements in the resulting set
1425
+ */
1426
+ sinterstore(
1427
+ destination: RedisClient.KeyLike,
1428
+ key: RedisClient.KeyLike,
1429
+ ...keys: RedisClient.KeyLike[]
1430
+ ): Promise<number>;
1431
+
1432
+ /**
1433
+ * Get the cardinality of the intersection of multiple sets
1434
+ * @param numkeys The number of keys to intersect
1435
+ * @param key The first set key
1436
+ * @param args Additional set keys and optional LIMIT argument
1437
+ * @returns Promise that resolves with the number of elements in the intersection
1438
+ */
1439
+ sintercard(
1440
+ numkeys: number,
1441
+ key: RedisClient.KeyLike,
1442
+ ...args: (RedisClient.KeyLike | "LIMIT" | number)[]
1443
+ ): Promise<number>;
1444
+
1445
+ /**
1446
+ * Get the length of the value stored in a key
1447
+ * @param key The key to check
1448
+ * @returns Promise that resolves with the length of the string value, or 0
1449
+ * if the key doesn't exist
1450
+ */
1451
+ strlen(key: RedisClient.KeyLike): Promise<number>;
1452
+
1453
+ /**
1454
+ * Get the union of multiple sets
1455
+ * @param key The first set key
1456
+ * @param keys Additional set keys to union
1457
+ * @returns Promise that resolves with an array of members in the union
1458
+ */
1459
+ sunion(key: RedisClient.KeyLike, ...keys: RedisClient.KeyLike[]): Promise<string[]>;
1460
+
1461
+ /**
1462
+ * Store the union of multiple sets in a key
1463
+ * @param destination The destination key to store the result
1464
+ * @param key The first set key
1465
+ * @param keys Additional set keys to union
1466
+ * @returns Promise that resolves with the number of elements in the resulting set
1467
+ */
1468
+ sunionstore(
1469
+ destination: RedisClient.KeyLike,
1470
+ key: RedisClient.KeyLike,
1471
+ ...keys: RedisClient.KeyLike[]
1472
+ ): Promise<number>;
1473
+
1474
+ /**
1475
+ * Determine the type of value stored at key
1476
+ *
1477
+ * The TYPE command returns the string representation of the type of the
1478
+ * value stored at key. The different types that can be returned are:
1479
+ * string, list, set, zset, hash and stream.
1480
+ *
1481
+ * @param key The key to check
1482
+ * @returns Promise that resolves with the type of value stored at key, or
1483
+ * "none" if the key doesn't exist
1484
+ *
1485
+ * @example
1486
+ * ```ts
1487
+ * await redis.set("mykey", "Hello");
1488
+ * console.log(await redis.type("mykey")); // "string"
1489
+ *
1490
+ * await redis.lpush("mylist", "value");
1491
+ * console.log(await redis.type("mylist")); // "list"
1492
+ *
1493
+ * await redis.sadd("myset", "value");
1494
+ * console.log(await redis.type("myset")); // "set"
1495
+ *
1496
+ * await redis.hset("myhash", "field", "value");
1497
+ * console.log(await redis.type("myhash")); // "hash"
1498
+ *
1499
+ * console.log(await redis.type("nonexistent")); // "none"
1500
+ * ```
1501
+ */
1502
+ type(key: RedisClient.KeyLike): Promise<"none" | "string" | "list" | "set" | "zset" | "hash" | "stream">;
1503
+
468
1504
  /**
469
1505
  * Get the number of members in a sorted set
470
1506
  * @param key The sorted set key
@@ -473,21 +1509,87 @@ declare module "bun" {
473
1509
  */
474
1510
  zcard(key: RedisClient.KeyLike): Promise<number>;
475
1511
 
1512
+ /**
1513
+ * Count the members in a sorted set with scores within the given range
1514
+ * @param key The sorted set key
1515
+ * @param min Minimum score (inclusive, use "-inf" for negative infinity)
1516
+ * @param max Maximum score (inclusive, use "+inf" for positive infinity)
1517
+ * @returns Promise that resolves with the count of elements in the specified score range
1518
+ */
1519
+ zcount(key: RedisClient.KeyLike, min: string | number, max: string | number): Promise<number>;
1520
+
1521
+ /**
1522
+ * Count the members in a sorted set within a lexicographical range
1523
+ * @param key The sorted set key
1524
+ * @param min Minimum value (use "[" for inclusive, "(" for exclusive, e.g., "[aaa")
1525
+ * @param max Maximum value (use "[" for inclusive, "(" for exclusive, e.g., "[zzz")
1526
+ * @returns Promise that resolves with the count of elements in the specified range
1527
+ */
1528
+ zlexcount(key: RedisClient.KeyLike, min: string, max: string): Promise<number>;
1529
+
476
1530
  /**
477
1531
  * Remove and return members with the highest scores in a sorted set
478
1532
  * @param key The sorted set key
479
- * @returns Promise that resolves with the removed member and its score, or
480
- * null if the set is empty
1533
+ * @returns Promise that resolves with either [member, score] or empty
1534
+ * array if the set is empty
481
1535
  */
482
- zpopmax(key: RedisClient.KeyLike): Promise<string | null>;
1536
+ zpopmax(key: RedisClient.KeyLike): Promise<[string, number] | []>;
1537
+
1538
+ /**
1539
+ * Remove and return members with the highest scores in a sorted set
1540
+ * @param key The sorted set key
1541
+ * @param count Optional number of members to pop (default: 1)
1542
+ * @returns Promise that resolves with an array of [member, score] tuples
1543
+ */
1544
+ zpopmax(key: RedisClient.KeyLike, count: number): Promise<Array<[string, number]>>;
483
1545
 
484
1546
  /**
485
1547
  * Remove and return members with the lowest scores in a sorted set
486
1548
  * @param key The sorted set key
487
- * @returns Promise that resolves with the removed member and its score, or
488
- * null if the set is empty
1549
+ * @returns Promise that resolves with array of [member, score] tuples, or
1550
+ * empty array if the set is empty
1551
+ */
1552
+ zpopmin(key: RedisClient.KeyLike): Promise<[string, number] | []>;
1553
+
1554
+ /**
1555
+ * Remove and return members with the lowest scores in a sorted set
1556
+ * @param key The sorted set key
1557
+ * @param count Optional number of members to pop (default: 1)
1558
+ * @returns Promise that resolves with an array of [member, score] tuples
1559
+ */
1560
+ zpopmin(key: RedisClient.KeyLike, count: number): Promise<[string, number][]>;
1561
+
1562
+ /**
1563
+ * Remove and return the member with the lowest score from one or more sorted sets, or block until one is available
1564
+ * @param args Keys followed by timeout in seconds (e.g., "key1", "key2", 1.0)
1565
+ * @returns Promise that resolves with [key, member, score] or null if timeout
1566
+ * @example
1567
+ * ```ts
1568
+ * // Block for up to 1 second waiting for an element
1569
+ * const result = await redis.bzpopmin("myzset", 1.0);
1570
+ * if (result) {
1571
+ * const [key, member, score] = result;
1572
+ * console.log(`Popped ${member} with score ${score} from ${key}`);
1573
+ * }
1574
+ * ```
1575
+ */
1576
+ bzpopmin(...args: (RedisClient.KeyLike | number)[]): Promise<[string, string, number] | null>;
1577
+
1578
+ /**
1579
+ * Remove and return the member with the highest score from one or more sorted sets, or block until one is available
1580
+ * @param args Keys followed by timeout in seconds (e.g., "key1", "key2", 1.0)
1581
+ * @returns Promise that resolves with [key, member, score] or null if timeout
1582
+ * @example
1583
+ * ```ts
1584
+ * // Block for up to 1 second waiting for an element
1585
+ * const result = await redis.bzpopmax("myzset", 1.0);
1586
+ * if (result) {
1587
+ * const [key, member, score] = result;
1588
+ * console.log(`Popped ${member} with score ${score} from ${key}`);
1589
+ * }
1590
+ * ```
489
1591
  */
490
- zpopmin(key: RedisClient.KeyLike): Promise<string | null>;
1592
+ bzpopmax(...args: (RedisClient.KeyLike | number)[]): Promise<[string, string, number] | null>;
491
1593
 
492
1594
  /**
493
1595
  * Get one or multiple random members from a sorted set
@@ -497,6 +1599,187 @@ declare module "bun" {
497
1599
  */
498
1600
  zrandmember(key: RedisClient.KeyLike): Promise<string | null>;
499
1601
 
1602
+ /**
1603
+ * Get one or multiple random members from a sorted set
1604
+ * @param key The sorted set key
1605
+ * @returns Promise that resolves with a random member, or null if the set
1606
+ * is empty
1607
+ */
1608
+ zrandmember(key: RedisClient.KeyLike, count: number): Promise<string[] | null>;
1609
+
1610
+ /**
1611
+ * Get one or multiple random members from a sorted set, with scores
1612
+ * @param key The sorted set key
1613
+ * @returns Promise that resolves with a random member, or null if the set
1614
+ * is empty
1615
+ */
1616
+ zrandmember(key: RedisClient.KeyLike, count: number, withscores: "WITHSCORES"): Promise<[string, number][] | null>;
1617
+
1618
+ /**
1619
+ * Return a range of members in a sorted set with their scores
1620
+ *
1621
+ * @param key The sorted set key
1622
+ * @param start The starting index
1623
+ * @param stop The stopping index
1624
+ * @param withscores Return members with their scores
1625
+ * @returns Promise that resolves with an array of [member, score, member, score, ...]
1626
+ *
1627
+ * @example
1628
+ * ```ts
1629
+ * const results = await redis.zrange("myzset", 0, -1, "WITHSCORES");
1630
+ * // Returns ["member1", "1.5", "member2", "2.5", ...]
1631
+ * ```
1632
+ */
1633
+ zrange(
1634
+ key: RedisClient.KeyLike,
1635
+ start: string | number,
1636
+ stop: string | number,
1637
+ withscores: "WITHSCORES",
1638
+ ): Promise<[string, number][]>;
1639
+
1640
+ /**
1641
+ * Return a range of members in a sorted set by score
1642
+ *
1643
+ * @param key The sorted set key
1644
+ * @param start The minimum score (use "-inf" for negative infinity, "(" prefix for exclusive)
1645
+ * @param stop The maximum score (use "+inf" for positive infinity, "(" prefix for exclusive)
1646
+ * @param byscore Indicates score-based range
1647
+ * @returns Promise that resolves with an array of members with scores in the range
1648
+ *
1649
+ * @example
1650
+ * ```ts
1651
+ * // Get members with score between 1 and 3
1652
+ * const members = await redis.zrange("myzset", "1", "3", "BYSCORE");
1653
+ *
1654
+ * // Get members with score > 1 and <= 3 (exclusive start)
1655
+ * const members2 = await redis.zrange("myzset", "(1", "3", "BYSCORE");
1656
+ * ```
1657
+ */
1658
+ zrange(
1659
+ key: RedisClient.KeyLike,
1660
+ start: string | number,
1661
+ stop: string | number,
1662
+ byscore: "BYSCORE",
1663
+ ): Promise<string[]>;
1664
+
1665
+ /**
1666
+ * Return a range of members in a sorted set lexicographically
1667
+ *
1668
+ * @param key The sorted set key
1669
+ * @param start The minimum lexicographical value (use "-" for start, "[" for inclusive, "(" for exclusive)
1670
+ * @param stop The maximum lexicographical value (use "+" for end, "[" for inclusive, "(" for exclusive)
1671
+ * @param bylex Indicates lexicographical range
1672
+ * @returns Promise that resolves with an array of members in the lexicographical range
1673
+ *
1674
+ * @example
1675
+ * ```ts
1676
+ * // Get members lexicographically from "a" to "c" (inclusive)
1677
+ * const members = await redis.zrange("myzset", "[a", "[c", "BYLEX");
1678
+ * ```
1679
+ */
1680
+ zrange(key: RedisClient.KeyLike, start: string, stop: string, bylex: "BYLEX"): Promise<string[]>;
1681
+
1682
+ /**
1683
+ * Return a range of members in a sorted set with various options
1684
+ *
1685
+ * @param key The sorted set key
1686
+ * @param start The starting value (index, score, or lex depending on options)
1687
+ * @param stop The stopping value
1688
+ * @param options Additional options (BYSCORE, BYLEX, REV, LIMIT offset count, WITHSCORES)
1689
+ * @returns Promise that resolves with an array of members (or with scores if WITHSCORES)
1690
+ *
1691
+ * @example
1692
+ * ```ts
1693
+ * // Get members by score with limit
1694
+ * const members = await redis.zrange("myzset", "1", "10", "BYSCORE", "LIMIT", "0", "5");
1695
+ *
1696
+ * // Get members in reverse order with scores
1697
+ * const reversed = await redis.zrange("myzset", "0", "-1", "REV", "WITHSCORES");
1698
+ * ```
1699
+ */
1700
+ zrange(
1701
+ key: RedisClient.KeyLike,
1702
+ start: string | number,
1703
+ stop: string | number,
1704
+ ...options: string[]
1705
+ ): Promise<string[]>;
1706
+
1707
+ /**
1708
+ * Return a range of members in a sorted set
1709
+ *
1710
+ * Returns the specified range of elements in the sorted set stored at key.
1711
+ * The elements are considered to be ordered from the lowest to the highest score by default.
1712
+ *
1713
+ * @param key The sorted set key
1714
+ * @param start The starting index (0-based, can be negative to count from end)
1715
+ * @param stop The stopping index (0-based, can be negative to count from end)
1716
+ * @returns Promise that resolves with an array of members in the specified range
1717
+ *
1718
+ * @example
1719
+ * ```ts
1720
+ * // Get all members
1721
+ * const members = await redis.zrange("myzset", 0, -1);
1722
+ *
1723
+ * // Get first 3 members
1724
+ * const top3 = await redis.zrange("myzset", 0, 2);
1725
+ * ```
1726
+ */
1727
+ zrange(key: RedisClient.KeyLike, start: string | number, stop: string | number): Promise<string[]>;
1728
+
1729
+ /**
1730
+ * Return a range of members in a sorted set, by index, with scores ordered from high to low
1731
+ *
1732
+ * This is equivalent to ZRANGE with the REV option. Returns members in reverse order.
1733
+ *
1734
+ * @param key The sorted set key
1735
+ * @param start The starting index (0-based, can be negative to count from end)
1736
+ * @param stop The stopping index (0-based, can be negative to count from end)
1737
+ * @returns Promise that resolves with an array of members in reverse order
1738
+ *
1739
+ * @example
1740
+ * ```ts
1741
+ * // Get all members in reverse order (highest to lowest score)
1742
+ * const members = await redis.zrevrange("myzset", 0, -1);
1743
+ *
1744
+ * // Get top 3 members with highest scores
1745
+ * const top3 = await redis.zrevrange("myzset", 0, 2);
1746
+ * ```
1747
+ */
1748
+ zrevrange(key: RedisClient.KeyLike, start: number, stop: number): Promise<string[]>;
1749
+
1750
+ /**
1751
+ * Return a range of members in a sorted set with their scores, ordered from high to low
1752
+ *
1753
+ * @param key The sorted set key
1754
+ * @param start The starting index
1755
+ * @param stop The stopping index
1756
+ * @param withscores Return members with their scores
1757
+ * @returns Promise that resolves with an array of [member, score, member, score, ...] in reverse order
1758
+ *
1759
+ * @example
1760
+ * ```ts
1761
+ * const results = await redis.zrevrange("myzset", 0, -1, "WITHSCORES");
1762
+ * // Returns ["member3", "3.5", "member2", "2.5", "member1", "1.5", ...]
1763
+ * ```
1764
+ */
1765
+ zrevrange(
1766
+ key: RedisClient.KeyLike,
1767
+ start: number,
1768
+ stop: number,
1769
+ withscores: "WITHSCORES",
1770
+ ): Promise<[string, number][]>;
1771
+
1772
+ /**
1773
+ * Return a range of members in a sorted set with options, ordered from high to low
1774
+ *
1775
+ * @param key The sorted set key
1776
+ * @param start The starting index
1777
+ * @param stop The stopping index
1778
+ * @param options Additional options (WITHSCORES)
1779
+ * @returns Promise that resolves with an array of members (or with scores if WITHSCORES)
1780
+ */
1781
+ zrevrange(key: RedisClient.KeyLike, start: number, stop: number, ...options: string[]): Promise<string[]>;
1782
+
500
1783
  /**
501
1784
  * Append a value to a key
502
1785
  * @param key The key to append to
@@ -513,7 +1796,30 @@ declare module "bun" {
513
1796
  * @returns Promise that resolves with the old value, or null if the key
514
1797
  * didn't exist
515
1798
  */
516
- getset(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<string | null>;
1799
+ getset(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<string | null>;
1800
+
1801
+ /**
1802
+ * Insert an element before or after another element in a list
1803
+ * @param key The list key
1804
+ * @param position "BEFORE" or "AFTER" to specify where to insert
1805
+ * @param pivot The pivot element to insert before or after
1806
+ * @param element The element to insert
1807
+ * @returns Promise that resolves with the length of the list after insert, -1 if pivot not found, or 0 if key doesn't exist
1808
+ *
1809
+ * @example
1810
+ * ```ts
1811
+ * await redis.lpush("mylist", "World");
1812
+ * await redis.lpush("mylist", "Hello");
1813
+ * await redis.linsert("mylist", "BEFORE", "World", "There");
1814
+ * // List is now: ["Hello", "There", "World"]
1815
+ * ```
1816
+ */
1817
+ linsert(
1818
+ key: RedisClient.KeyLike,
1819
+ position: "BEFORE" | "AFTER",
1820
+ pivot: RedisClient.KeyLike,
1821
+ element: RedisClient.KeyLike,
1822
+ ): Promise<number>;
517
1823
 
518
1824
  /**
519
1825
  * Prepend one or multiple values to a list
@@ -522,7 +1828,7 @@ declare module "bun" {
522
1828
  * @returns Promise that resolves with the length of the list after the push
523
1829
  * operation
524
1830
  */
525
- lpush(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
1831
+ lpush(key: RedisClient.KeyLike, value: RedisClient.KeyLike, ...rest: RedisClient.KeyLike[]): Promise<number>;
526
1832
 
527
1833
  /**
528
1834
  * Prepend a value to a list, only if the list exists
@@ -533,6 +1839,41 @@ declare module "bun" {
533
1839
  */
534
1840
  lpushx(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
535
1841
 
1842
+ /**
1843
+ * Remove elements from a list
1844
+ * @param key The list key
1845
+ * @param count Number of elements to remove
1846
+ * - count > 0: Remove count occurrences from head to tail
1847
+ * - count < 0: Remove count occurrences from tail to head
1848
+ * - count = 0: Remove all occurrences
1849
+ * @param element The element to remove
1850
+ * @returns Promise that resolves with the number of elements removed
1851
+ *
1852
+ * @example
1853
+ * ```ts
1854
+ * await redis.rpush("mylist", "hello", "hello", "world", "hello");
1855
+ * await redis.lrem("mylist", 2, "hello"); // Removes first 2 "hello"
1856
+ * // List is now: ["world", "hello"]
1857
+ * ```
1858
+ */
1859
+ lrem(key: RedisClient.KeyLike, count: number, element: RedisClient.KeyLike): Promise<number>;
1860
+
1861
+ /**
1862
+ * Trim a list to the specified range
1863
+ * @param key The list key
1864
+ * @param start The start index (0-based, can be negative)
1865
+ * @param stop The stop index (0-based, can be negative)
1866
+ * @returns Promise that resolves with "OK"
1867
+ *
1868
+ * @example
1869
+ * ```ts
1870
+ * await redis.rpush("mylist", "one", "two", "three", "four");
1871
+ * await redis.ltrim("mylist", 1, 2);
1872
+ * // List is now: ["two", "three"]
1873
+ * ```
1874
+ */
1875
+ ltrim(key: RedisClient.KeyLike, start: number, stop: number): Promise<string>;
1876
+
536
1877
  /**
537
1878
  * Add one or more members to a HyperLogLog
538
1879
  * @param key The HyperLogLog key
@@ -549,7 +1890,7 @@ declare module "bun" {
549
1890
  * @returns Promise that resolves with the length of the list after the push
550
1891
  * operation
551
1892
  */
552
- rpush(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
1893
+ rpush(key: RedisClient.KeyLike, value: RedisClient.KeyLike, ...rest: RedisClient.KeyLike[]): Promise<number>;
553
1894
 
554
1895
  /**
555
1896
  * Append a value to a list, only if the list exists
@@ -558,25 +1899,594 @@ declare module "bun" {
558
1899
  * @returns Promise that resolves with the length of the list after the push
559
1900
  * operation, or 0 if the list doesn't exist
560
1901
  */
561
- rpushx(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
1902
+ rpushx(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
1903
+
1904
+ /**
1905
+ * Set the value of a key, only if the key does not exist
1906
+ * @param key The key to set
1907
+ * @param value The value to set
1908
+ * @returns Promise that resolves with 1 if the key was set, 0 if the key
1909
+ * was not set
1910
+ */
1911
+ setnx(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
1912
+
1913
+ /**
1914
+ * Set key to hold the string value with expiration time in seconds
1915
+ * @param key The key to set
1916
+ * @param seconds The expiration time in seconds
1917
+ * @param value The value to set
1918
+ * @returns Promise that resolves with "OK" on success
1919
+ *
1920
+ * @example
1921
+ * ```ts
1922
+ * await redis.setex("mykey", 10, "Hello");
1923
+ * // Key will expire after 10 seconds
1924
+ * ```
1925
+ */
1926
+ setex(key: RedisClient.KeyLike, seconds: number, value: RedisClient.KeyLike): Promise<"OK">;
1927
+
1928
+ /**
1929
+ * Set key to hold the string value with expiration time in milliseconds
1930
+ * @param key The key to set
1931
+ * @param milliseconds The expiration time in milliseconds
1932
+ * @param value The value to set
1933
+ * @returns Promise that resolves with "OK" on success
1934
+ *
1935
+ * @example
1936
+ * ```ts
1937
+ * await redis.psetex("mykey", 10000, "Hello");
1938
+ * // Key will expire after 10000 milliseconds (10 seconds)
1939
+ * ```
1940
+ */
1941
+ psetex(key: RedisClient.KeyLike, milliseconds: number, value: RedisClient.KeyLike): Promise<"OK">;
1942
+
1943
+ /**
1944
+ * Get the score associated with the given member in a sorted set
1945
+ * @param key The sorted set key
1946
+ * @param member The member to get the score for
1947
+ * @returns Promise that resolves with the score of the member as a number,
1948
+ * or null if the member or key doesn't exist
1949
+ */
1950
+ zscore(key: RedisClient.KeyLike, member: string): Promise<number | null>;
1951
+
1952
+ /**
1953
+ * Increment the score of a member in a sorted set
1954
+ * @param key The sorted set key
1955
+ * @param increment The increment value
1956
+ * @param member The member to increment
1957
+ * @returns Promise that resolves with the new score
1958
+ */
1959
+ zincrby(key: RedisClient.KeyLike, increment: number, member: RedisClient.KeyLike): Promise<number>;
1960
+
1961
+ /**
1962
+ * Returns the scores associated with the specified members in the sorted set
1963
+ * @param key The sorted set key
1964
+ * @param member The first member to get the score for
1965
+ * @param members Additional members to get scores for
1966
+ * @returns Promise that resolves with an array of scores (number for each score, or null if member doesn't exist)
1967
+ */
1968
+ zmscore(
1969
+ key: RedisClient.KeyLike,
1970
+ member: RedisClient.KeyLike,
1971
+ ...members: RedisClient.KeyLike[]
1972
+ ): Promise<(number | null)[]>;
1973
+
1974
+ /**
1975
+ * Add one or more members to a sorted set, or update scores if they already exist
1976
+ *
1977
+ * ZADD adds all the specified members with the specified scores to the sorted set stored at key.
1978
+ * It is possible to specify multiple score / member pairs. If a specified member is already a
1979
+ * member of the sorted set, the score is updated and the element reinserted at the right position
1980
+ * to ensure the correct ordering.
1981
+ *
1982
+ * If key does not exist, a new sorted set with the specified members as sole members is created.
1983
+ * If the key exists but does not hold a sorted set, an error is returned.
1984
+ *
1985
+ * The score values should be the string representation of a double precision floating point number.
1986
+ * +inf and -inf values are valid values as well.
1987
+ *
1988
+ * Options:
1989
+ * - NX: Only add new elements. Don't update already existing elements.
1990
+ * - XX: Only update elements that already exist. Never add elements.
1991
+ * - GT: Only update existing elements if the new score is greater than the current score. This flag doesn't prevent adding new elements.
1992
+ * - LT: Only update existing elements if the new score is less than the current score. This flag doesn't prevent adding new elements.
1993
+ * - CH: Modify the return value from the number of new elements added, to the total number of elements changed (CH is an abbreviation of changed).
1994
+ * - INCR: When this option is specified ZADD acts like ZINCRBY. Only one score-member pair can be specified in this mode.
1995
+ *
1996
+ * Note: The GT, LT and NX options are mutually exclusive.
1997
+ *
1998
+ * @param key The sorted set key
1999
+ * @param args Score-member pairs and optional flags (NX, XX, GT, LT, CH, INCR)
2000
+ * @returns Promise that resolves with the number of elements added (or changed if CH is used, or new score if INCR is used)
2001
+ *
2002
+ * @example
2003
+ * ```ts
2004
+ * // Add members with scores
2005
+ * await redis.zadd("myzset", "1", "one", "2", "two", "3", "three");
2006
+ *
2007
+ * // Add with NX option (only if member doesn't exist)
2008
+ * await redis.zadd("myzset", "NX", "4", "four");
2009
+ *
2010
+ * // Add with XX option (only if member exists)
2011
+ * await redis.zadd("myzset", "XX", "2.5", "two");
2012
+ *
2013
+ * // Add with CH option (return count of changed elements)
2014
+ * await redis.zadd("myzset", "CH", "5", "five", "2.1", "two");
2015
+ *
2016
+ * // Use INCR option (increment score)
2017
+ * await redis.zadd("myzset", "INCR", "1.5", "one");
2018
+ * ```
2019
+ */
2020
+ zadd(key: RedisClient.KeyLike, ...args: (string | number)[]): Promise<number>;
2021
+
2022
+ /**
2023
+ * Incrementally iterate sorted set elements and their scores
2024
+ *
2025
+ * The ZSCAN command is used in order to incrementally iterate over sorted set elements and their scores.
2026
+ * ZSCAN is a cursor based iterator. This means that at every call of the command, the server returns an
2027
+ * updated cursor that the user needs to use as the cursor argument in the next call.
2028
+ *
2029
+ * An iteration starts when the cursor is set to 0, and terminates when the cursor returned by the server is 0.
2030
+ *
2031
+ * ZSCAN and the other SCAN family commands are able to provide to the user a set of guarantees associated
2032
+ * to full iterations:
2033
+ * - A full iteration always retrieves all the elements that were present in the collection from the start
2034
+ * to the end of a full iteration. This means that if a given element is inside the collection when an
2035
+ * iteration is started, and is still there when an iteration terminates, then at some point ZSCAN returned it.
2036
+ * - A full iteration never returns any element that was NOT present in the collection from the start to the
2037
+ * end of a full iteration. So if an element was removed before the start of an iteration, and is never
2038
+ * added back to the collection for all the time an iteration lasts, ZSCAN ensures that this element will
2039
+ * never be returned.
2040
+ *
2041
+ * Options:
2042
+ * - MATCH pattern: Only return elements matching the pattern (glob-style)
2043
+ * - COUNT count: Amount of work done at every call (hint, not exact)
2044
+ *
2045
+ * @param key The sorted set key
2046
+ * @param cursor The cursor value (use 0 to start a new iteration)
2047
+ * @param options Additional ZSCAN options (MATCH pattern, COUNT hint, etc.)
2048
+ * @returns Promise that resolves with a tuple [cursor, [member1, score1, member2, score2, ...]]
2049
+ *
2050
+ * @example
2051
+ * ```ts
2052
+ * // Basic scan - iterate all elements
2053
+ * let cursor = "0";
2054
+ * const allElements: string[] = [];
2055
+ * do {
2056
+ * const [nextCursor, elements] = await redis.zscan("myzset", cursor);
2057
+ * allElements.push(...elements);
2058
+ * cursor = nextCursor;
2059
+ * } while (cursor !== "0");
2060
+ * ```
2061
+ *
2062
+ * @example
2063
+ * ```ts
2064
+ * // Scan with MATCH pattern
2065
+ * const [cursor, elements] = await redis.zscan("myzset", "0", "MATCH", "user:*");
2066
+ * ```
2067
+ *
2068
+ * @example
2069
+ * ```ts
2070
+ * // Scan with COUNT hint
2071
+ * const [cursor, elements] = await redis.zscan("myzset", "0", "COUNT", "100");
2072
+ * ```
2073
+ */
2074
+ zscan(key: RedisClient.KeyLike, cursor: string | number, ...options: string[]): Promise<[string, string[]]>;
2075
+
2076
+ /**
2077
+ * Remove one or more members from a sorted set
2078
+ * @param key The sorted set key
2079
+ * @param member The first member to remove
2080
+ * @param members Additional members to remove
2081
+ * @returns Promise that resolves with the number of members removed (not including non-existing members)
2082
+ */
2083
+ zrem(key: RedisClient.KeyLike, member: RedisClient.KeyLike, ...members: RedisClient.KeyLike[]): Promise<number>;
2084
+
2085
+ /**
2086
+ * Remove all members in a sorted set within the given lexicographical range
2087
+ * @param key The sorted set key
2088
+ * @param min Minimum value (use "[" for inclusive, "(" for exclusive, e.g., "[aaa")
2089
+ * @param max Maximum value (use "[" for inclusive, "(" for exclusive, e.g., "[zzz")
2090
+ * @returns Promise that resolves with the number of elements removed
2091
+ */
2092
+ zremrangebylex(key: RedisClient.KeyLike, min: string, max: string): Promise<number>;
2093
+
2094
+ /**
2095
+ * Remove all members in a sorted set within the given rank range
2096
+ * @param key The sorted set key
2097
+ * @param start Start rank (0-based, can be negative to indicate offset from end)
2098
+ * @param stop Stop rank (0-based, can be negative to indicate offset from end)
2099
+ * @returns Promise that resolves with the number of elements removed
2100
+ */
2101
+ zremrangebyrank(key: RedisClient.KeyLike, start: number, stop: number): Promise<number>;
2102
+
2103
+ /**
2104
+ * Remove all members in a sorted set within the given score range
2105
+ * @param key The sorted set key
2106
+ * @param min Minimum score (inclusive, use "-inf" for negative infinity, "(" prefix for exclusive)
2107
+ * @param max Maximum score (inclusive, use "+inf" for positive infinity, "(" prefix for exclusive)
2108
+ * @returns Promise that resolves with the number of elements removed
2109
+ */
2110
+ zremrangebyscore(key: RedisClient.KeyLike, min: string | number, max: string | number): Promise<number>;
2111
+
2112
+ /**
2113
+ * Return members in a sorted set within a lexicographical range
2114
+ *
2115
+ * When all the elements in a sorted set have the same score, this command
2116
+ * returns the elements between min and max in lexicographical order.
2117
+ *
2118
+ * Lex ranges:
2119
+ * - `[member` for inclusive lower bound
2120
+ * - `(member` for exclusive lower bound
2121
+ * - `-` for negative infinity
2122
+ * - `+` for positive infinity
2123
+ *
2124
+ * @param key The sorted set key (all members must have the same score)
2125
+ * @param min Minimum lexicographical value (use "-" for negative infinity, "[" or "(" for inclusive/exclusive)
2126
+ * @param max Maximum lexicographical value (use "+" for positive infinity, "[" or "(" for inclusive/exclusive)
2127
+ * @returns Promise that resolves with array of members
2128
+ *
2129
+ * @example
2130
+ * ```ts
2131
+ * await redis.send("ZADD", ["myzset", "0", "apple", "0", "banana", "0", "cherry"]);
2132
+ * const members = await redis.zrangebylex("myzset", "[banana", "[cherry");
2133
+ * // Returns: ["banana", "cherry"]
2134
+ * ```
2135
+ */
2136
+ zrangebylex(key: RedisClient.KeyLike, min: string, max: string): Promise<string[]>;
2137
+
2138
+ /**
2139
+ * Return members in a sorted set within a lexicographical range, with pagination
2140
+ *
2141
+ * @param key The sorted set key
2142
+ * @param min Minimum lexicographical value
2143
+ * @param max Maximum lexicographical value
2144
+ * @param limit The "LIMIT" keyword
2145
+ * @param offset The number of elements to skip
2146
+ * @param count The maximum number of elements to return
2147
+ * @returns Promise that resolves with array of members
2148
+ *
2149
+ * @example
2150
+ * ```ts
2151
+ * await redis.send("ZADD", ["myzset", "0", "a", "0", "b", "0", "c", "0", "d"]);
2152
+ * const result = await redis.zrangebylex("myzset", "-", "+", "LIMIT", 1, 2);
2153
+ * // Returns: ["b", "c"]
2154
+ * ```
2155
+ */
2156
+ zrangebylex(
2157
+ key: RedisClient.KeyLike,
2158
+ min: string,
2159
+ max: string,
2160
+ limit: "LIMIT",
2161
+ offset: number,
2162
+ count: number,
2163
+ ): Promise<string[]>;
2164
+
2165
+ /**
2166
+ * Return members in a sorted set within a lexicographical range, with options
2167
+ *
2168
+ * @param key The sorted set key
2169
+ * @param min Minimum lexicographical value
2170
+ * @param max Maximum lexicographical value
2171
+ * @param options Additional options (LIMIT offset count)
2172
+ * @returns Promise that resolves with array of members
2173
+ */
2174
+ zrangebylex(key: RedisClient.KeyLike, min: string, max: string, ...options: (string | number)[]): Promise<string[]>;
2175
+
2176
+ /**
2177
+ * Return members in a sorted set with scores within a given range
2178
+ *
2179
+ * Returns all the elements in the sorted set at key with a score between min
2180
+ * and max (inclusive by default). The elements are considered to be ordered
2181
+ * from low to high scores.
2182
+ *
2183
+ * Score ranges support:
2184
+ * - `-inf` and `+inf` for negative and positive infinity
2185
+ * - `(` prefix for exclusive bounds (e.g., `(5` means greater than 5, not including 5)
2186
+ *
2187
+ * @param key The sorted set key
2188
+ * @param min Minimum score (can be "-inf", a number, or prefixed with "(" for exclusive)
2189
+ * @param max Maximum score (can be "+inf", a number, or prefixed with "(" for exclusive)
2190
+ * @returns Promise that resolves with array of members
2191
+ *
2192
+ * @example
2193
+ * ```ts
2194
+ * await redis.send("ZADD", ["myzset", "1", "one", "2", "two", "3", "three"]);
2195
+ * const members = await redis.zrangebyscore("myzset", 1, 2);
2196
+ * // Returns: ["one", "two"]
2197
+ * ```
2198
+ */
2199
+ zrangebyscore(key: RedisClient.KeyLike, min: string | number, max: string | number): Promise<string[]>;
2200
+
2201
+ /**
2202
+ * Return members in a sorted set with scores within a given range, with scores
2203
+ *
2204
+ * @param key The sorted set key
2205
+ * @param min Minimum score
2206
+ * @param max Maximum score
2207
+ * @param withscores The "WITHSCORES" keyword to return scores along with members
2208
+ * @returns Promise that resolves with array of [member, score, member, score, ...]
2209
+ *
2210
+ * @example
2211
+ * ```ts
2212
+ * await redis.send("ZADD", ["myzset", "1", "one", "2", "two", "3", "three"]);
2213
+ * const result = await redis.zrangebyscore("myzset", 1, 2, "WITHSCORES");
2214
+ * // Returns: ["one", "1", "two", "2"]
2215
+ * ```
2216
+ */
2217
+ zrangebyscore(
2218
+ key: RedisClient.KeyLike,
2219
+ min: string | number,
2220
+ max: string | number,
2221
+ withscores: "WITHSCORES",
2222
+ ): Promise<[string, number][]>;
2223
+
2224
+ /**
2225
+ * Return members in a sorted set with scores within a given range, with pagination
2226
+ *
2227
+ * @param key The sorted set key
2228
+ * @param min Minimum score
2229
+ * @param max Maximum score
2230
+ * @param limit The "LIMIT" keyword
2231
+ * @param offset The number of elements to skip
2232
+ * @param count The maximum number of elements to return
2233
+ * @returns Promise that resolves with array of members
2234
+ *
2235
+ * @example
2236
+ * ```ts
2237
+ * await redis.send("ZADD", ["myzset", "1", "one", "2", "two", "3", "three", "4", "four"]);
2238
+ * const result = await redis.zrangebyscore("myzset", "-inf", "+inf", "LIMIT", 1, 2);
2239
+ * // Returns: ["two", "three"]
2240
+ * ```
2241
+ */
2242
+ zrangebyscore(
2243
+ key: RedisClient.KeyLike,
2244
+ min: string | number,
2245
+ max: string | number,
2246
+ limit: "LIMIT",
2247
+ offset: number,
2248
+ count: number,
2249
+ ): Promise<string[]>;
2250
+
2251
+ /**
2252
+ * Return members in a sorted set with scores within a given range, with the score values
2253
+ *
2254
+ * @param key The sorted set key
2255
+ * @param min Minimum score
2256
+ * @param max Maximum score
2257
+ * @param options Additional options (WITHSCORES, LIMIT offset count)
2258
+ * @returns Promise that resolves with array of members (and scores if WITHSCORES is used)
2259
+ */
2260
+ zrangebyscore(
2261
+ key: RedisClient.KeyLike,
2262
+ min: string | number,
2263
+ max: string | number,
2264
+ withscores: "WITHSCORES",
2265
+ ...options: (string | number)[]
2266
+ ): Promise<[string, number][]>;
2267
+
2268
+ /**
2269
+ * Return members in a sorted set with scores within a given range, with the score values
2270
+ *
2271
+ * @param key The sorted set key
2272
+ * @param min Minimum score
2273
+ * @param max Maximum score
2274
+ * @param options Additional options (WITHSCORES, LIMIT offset count)
2275
+ * @returns Promise that resolves with array of members (and scores if WITHSCORES is used)
2276
+ */
2277
+ zrangebyscore(
2278
+ key: RedisClient.KeyLike,
2279
+ min: string | number,
2280
+ max: string | number,
2281
+ withscores: "WITHSCORES",
2282
+ limit: "LIMIT",
2283
+ offset: number,
2284
+ count: number,
2285
+ ...options: (string | number)[]
2286
+ ): Promise<[string, number][]>;
2287
+
2288
+ /**
2289
+ * Return members in a sorted set with scores within a given range, with various options
2290
+ *
2291
+ * @param key The sorted set key
2292
+ * @param min Minimum score
2293
+ * @param max Maximum score
2294
+ * @param options Additional options (WITHSCORES, LIMIT offset count)
2295
+ * @returns Promise that resolves with array of members (and scores if WITHSCORES is used)
2296
+ */
2297
+ zrangebyscore(
2298
+ key: RedisClient.KeyLike,
2299
+ min: string | number,
2300
+ max: string | number,
2301
+ ...options: (string | number)[]
2302
+ ): Promise<string[]>;
2303
+
2304
+ /**
2305
+ * Return members in a sorted set with scores within a given range, ordered from high to low
2306
+ *
2307
+ * Returns all the elements in the sorted set at key with a score between max
2308
+ * and min (note: max comes before min). The elements are considered to be
2309
+ * ordered from high to low scores.
2310
+ *
2311
+ * Score ranges support:
2312
+ * - `-inf` and `+inf` for negative and positive infinity
2313
+ * - `(` prefix for exclusive bounds (e.g., `(5` means less than 5, not including 5)
2314
+ *
2315
+ * @param key The sorted set key
2316
+ * @param max Maximum score (can be "+inf", a number, or prefixed with "(" for exclusive)
2317
+ * @param min Minimum score (can be "-inf", a number, or prefixed with "(" for exclusive)
2318
+ * @returns Promise that resolves with array of members
2319
+ *
2320
+ * @example
2321
+ * ```ts
2322
+ * await redis.send("ZADD", ["myzset", "1", "one", "2", "two", "3", "three"]);
2323
+ * const members = await redis.zrevrangebyscore("myzset", 2, 1);
2324
+ * // Returns: ["two", "one"]
2325
+ * ```
2326
+ */
2327
+ zrevrangebyscore(key: RedisClient.KeyLike, max: string | number, min: string | number): Promise<string[]>;
2328
+
2329
+ /**
2330
+ * Return members in a sorted set with scores within a given range, ordered from high to low, with scores
2331
+ *
2332
+ * @param key The sorted set key
2333
+ * @param max Maximum score
2334
+ * @param min Minimum score
2335
+ * @param withscores The "WITHSCORES" keyword to return scores along with members
2336
+ * @returns Promise that resolves with array of [member, score, member, score, ...]
2337
+ *
2338
+ * @example
2339
+ * ```ts
2340
+ * await redis.send("ZADD", ["myzset", "1", "one", "2", "two", "3", "three"]);
2341
+ * const result = await redis.zrevrangebyscore("myzset", 2, 1, "WITHSCORES");
2342
+ * // Returns: ["two", "2", "one", "1"]
2343
+ * ```
2344
+ */
2345
+ zrevrangebyscore(
2346
+ key: RedisClient.KeyLike,
2347
+ max: string | number,
2348
+ min: string | number,
2349
+ withscores: "WITHSCORES",
2350
+ ): Promise<[string, number][]>;
2351
+
2352
+ /**
2353
+ * Return members in a sorted set with scores within a given range, ordered from high to low, with pagination
2354
+ *
2355
+ * @param key The sorted set key
2356
+ * @param max Maximum score
2357
+ * @param min Minimum score
2358
+ * @param limit The "LIMIT" keyword
2359
+ * @param offset The number of elements to skip
2360
+ * @param count The maximum number of elements to return
2361
+ * @returns Promise that resolves with array of members
2362
+ */
2363
+ zrevrangebyscore(
2364
+ key: RedisClient.KeyLike,
2365
+ max: string | number,
2366
+ min: string | number,
2367
+ limit: "LIMIT",
2368
+ offset: number,
2369
+ count: number,
2370
+ ): Promise<string[]>;
2371
+
2372
+ /**
2373
+ * Return members in a sorted set with scores within a given range, ordered from high to low, with options
2374
+ *
2375
+ * @param key The sorted set key
2376
+ * @param max Maximum score
2377
+ * @param min Minimum score
2378
+ * @param options Additional options (WITHSCORES, LIMIT offset count)
2379
+ * @returns Promise that resolves with array of members (and scores if WITHSCORES is used)
2380
+ */
2381
+ zrevrangebyscore(
2382
+ key: RedisClient.KeyLike,
2383
+ max: string | number,
2384
+ min: string | number,
2385
+ ...options: (string | number)[]
2386
+ ): Promise<string[]>;
2387
+
2388
+ /**
2389
+ * Return members in a sorted set within a lexicographical range, ordered from high to low
2390
+ *
2391
+ * All members in a sorted set must have the same score for this command to work correctly.
2392
+ * The max and min arguments have the same meaning as in ZRANGEBYLEX, but in reverse order.
2393
+ *
2394
+ * Use "[" for inclusive bounds and "(" for exclusive bounds. Use "-" for negative infinity and "+" for positive infinity.
2395
+ *
2396
+ * @param key The sorted set key
2397
+ * @param max The maximum lexicographical value (inclusive with "[", exclusive with "(")
2398
+ * @param min The minimum lexicographical value (inclusive with "[", exclusive with "(")
2399
+ * @param options Optional LIMIT clause: ["LIMIT", offset, count]
2400
+ * @returns Promise that resolves with an array of members in reverse lexicographical order
2401
+ *
2402
+ * @example
2403
+ * ```ts
2404
+ * // Add members with same score
2405
+ * await redis.send("ZADD", ["myzset", "0", "a", "0", "b", "0", "c", "0", "d"]);
2406
+ *
2407
+ * // Get range from highest to lowest
2408
+ * const members = await redis.zrevrangebylex("myzset", "[d", "[b");
2409
+ * console.log(members); // ["d", "c", "b"]
2410
+ *
2411
+ * // With LIMIT
2412
+ * const limited = await redis.zrevrangebylex("myzset", "+", "-", "LIMIT", "0", "2");
2413
+ * console.log(limited); // ["d", "c"] (first 2 members)
2414
+ * ```
2415
+ */
2416
+ zrevrangebylex(key: RedisClient.KeyLike, max: string, min: string, ...options: string[]): Promise<string[]>;
2417
+
2418
+ /**
2419
+ * Store a range of members from a sorted set into a destination key
2420
+ *
2421
+ * This command is like ZRANGE but stores the result in a destination key instead of returning it.
2422
+ * Supports all the same options as ZRANGE including BYSCORE, BYLEX, REV, and LIMIT.
2423
+ *
2424
+ * @param destination The destination key to store results
2425
+ * @param source The source sorted set key
2426
+ * @param start The starting index or score
2427
+ * @param stop The ending index or score
2428
+ * @param options Optional flags: ["BYSCORE"], ["BYLEX"], ["REV"], ["LIMIT", offset, count]
2429
+ * @returns Promise that resolves with the number of elements in the resulting sorted set
2430
+ *
2431
+ * @example
2432
+ * ```ts
2433
+ * // Add members to source set
2434
+ * await redis.send("ZADD", ["source", "1", "one", "2", "two", "3", "three"]);
2435
+ *
2436
+ * // Store range by rank
2437
+ * const count1 = await redis.zrangestore("dest1", "source", 0, 1);
2438
+ * console.log(count1); // 2
2439
+ *
2440
+ * // Store range by score
2441
+ * const count2 = await redis.zrangestore("dest2", "source", "1", "2", "BYSCORE");
2442
+ * console.log(count2); // 2
2443
+ *
2444
+ * // Store in reverse order with limit
2445
+ * const count3 = await redis.zrangestore("dest3", "source", "0", "-1", "REV", "LIMIT", "0", "2");
2446
+ * console.log(count3); // 2
2447
+ * ```
2448
+ */
2449
+ zrangestore(
2450
+ destination: RedisClient.KeyLike,
2451
+ source: RedisClient.KeyLike,
2452
+ start: string | number,
2453
+ stop: string | number,
2454
+ ...options: string[]
2455
+ ): Promise<number>;
2456
+
2457
+ /**
2458
+ * Determine the index of a member in a sorted set
2459
+ * @param key The sorted set key
2460
+ * @param member The member to find
2461
+ * @returns Promise that resolves with the rank (index) of the member, or null if the member doesn't exist
2462
+ */
2463
+ zrank(key: RedisClient.KeyLike, member: string): Promise<number | null>;
2464
+
2465
+ /**
2466
+ * Determine the index of a member in a sorted set with score
2467
+ * @param key The sorted set key
2468
+ * @param member The member to find
2469
+ * @param withscore "WITHSCORE" to include the score
2470
+ * @returns Promise that resolves with [rank, score] or null if the member doesn't exist
2471
+ */
2472
+ zrank(key: RedisClient.KeyLike, member: string, withscore: "WITHSCORE"): Promise<[number, number] | null>;
562
2473
 
563
2474
  /**
564
- * Set the value of a key, only if the key does not exist
565
- * @param key The key to set
566
- * @param value The value to set
567
- * @returns Promise that resolves with 1 if the key was set, 0 if the key
568
- * was not set
2475
+ * Determine the index of a member in a sorted set, with scores ordered from high to low
2476
+ * @param key The sorted set key
2477
+ * @param member The member to find
2478
+ * @returns Promise that resolves with the rank (index) of the member, or null if the member doesn't exist
569
2479
  */
570
- setnx(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
2480
+ zrevrank(key: RedisClient.KeyLike, member: string): Promise<number | null>;
571
2481
 
572
2482
  /**
573
- * Get the score associated with the given member in a sorted set
2483
+ * Determine the index of a member in a sorted set with score, with scores ordered from high to low
574
2484
  * @param key The sorted set key
575
- * @param member The member to get the score for
576
- * @returns Promise that resolves with the score of the member as a string,
577
- * or null if the member or key doesn't exist
2485
+ * @param member The member to find
2486
+ * @param withscore "WITHSCORE" to include the score
2487
+ * @returns Promise that resolves with [rank, score] or null if the member doesn't exist
578
2488
  */
579
- zscore(key: RedisClient.KeyLike, member: string): Promise<string | null>;
2489
+ zrevrank(key: RedisClient.KeyLike, member: string, withscore: "WITHSCORE"): Promise<[number, number] | null>;
580
2490
 
581
2491
  /**
582
2492
  * Get the values of all specified keys
@@ -586,6 +2496,55 @@ declare module "bun" {
586
2496
  */
587
2497
  mget(...keys: RedisClient.KeyLike[]): Promise<(string | null)[]>;
588
2498
 
2499
+ /**
2500
+ * Set multiple keys to multiple values atomically
2501
+ *
2502
+ * Sets the given keys to their respective values. MSET replaces existing
2503
+ * values with new values, just as regular SET. Use MSETNX if you don't want
2504
+ * to overwrite existing values.
2505
+ *
2506
+ * MSET is atomic, so all given keys are set at once. It is not possible for
2507
+ * clients to see that some of the keys were updated while others are
2508
+ * unchanged.
2509
+ *
2510
+ * @param keyValuePairs Alternating keys and values (key1, value1, key2, value2, ...)
2511
+ * @returns Promise that resolves with "OK" on success
2512
+ *
2513
+ * @example
2514
+ * ```ts
2515
+ * await redis.mset("key1", "value1", "key2", "value2");
2516
+ * ```
2517
+ */
2518
+ mset(...keyValuePairs: RedisClient.KeyLike[]): Promise<"OK">;
2519
+
2520
+ /**
2521
+ * Set multiple keys to multiple values, only if none of the keys exist
2522
+ *
2523
+ * Sets the given keys to their respective values. MSETNX will not perform
2524
+ * any operation at all even if just a single key already exists.
2525
+ *
2526
+ * Because of this semantic, MSETNX can be used in order to set different
2527
+ * keys representing different fields of a unique logic object in a way that
2528
+ * ensures that either all the fields or none at all are set.
2529
+ *
2530
+ * MSETNX is atomic, so all given keys are set at once. It is not possible
2531
+ * for clients to see that some of the keys were updated while others are
2532
+ * unchanged.
2533
+ *
2534
+ * @param keyValuePairs Alternating keys and values (key1, value1, key2, value2, ...)
2535
+ * @returns Promise that resolves with 1 if all keys were set, 0 if no key was set
2536
+ *
2537
+ * @example
2538
+ * ```ts
2539
+ * // Returns 1 if keys don't exist
2540
+ * await redis.msetnx("key1", "value1", "key2", "value2");
2541
+ *
2542
+ * // Returns 0 if any key already exists
2543
+ * await redis.msetnx("key1", "newvalue", "key3", "value3");
2544
+ * ```
2545
+ */
2546
+ msetnx(...keyValuePairs: RedisClient.KeyLike[]): Promise<number>;
2547
+
589
2548
  /**
590
2549
  * Count the number of set bits (population counting) in a string
591
2550
  * @param key The key to count bits in
@@ -593,6 +2552,52 @@ declare module "bun" {
593
2552
  */
594
2553
  bitcount(key: RedisClient.KeyLike): Promise<number>;
595
2554
 
2555
+ /**
2556
+ * Returns the bit value at offset in the string value stored at key
2557
+ * @param key The key containing the string value
2558
+ * @param offset The bit offset (zero-based)
2559
+ * @returns Promise that resolves with the bit value (0 or 1) at the specified offset
2560
+ */
2561
+ getbit(key: RedisClient.KeyLike, offset: number): Promise<number>;
2562
+
2563
+ /**
2564
+ * Sets or clears the bit at offset in the string value stored at key
2565
+ * @param key The key to modify
2566
+ * @param offset The bit offset (zero-based)
2567
+ * @param value The bit value to set (0 or 1)
2568
+ * @returns Promise that resolves with the original bit value stored at offset
2569
+ */
2570
+ setbit(key: RedisClient.KeyLike, offset: number, value: 0 | 1): Promise<number>;
2571
+
2572
+ /**
2573
+ * Get a substring of the string stored at a key
2574
+ * @param key The key to get the substring from
2575
+ * @param start The starting offset (can be negative to count from the end)
2576
+ * @param end The ending offset (can be negative to count from the end)
2577
+ * @returns Promise that resolves with the substring, or an empty string if the key doesn't exist
2578
+ */
2579
+ getrange(key: RedisClient.KeyLike, start: number, end: number): Promise<string>;
2580
+
2581
+ /**
2582
+ * Get a substring of the string stored at a key
2583
+ * @param key The key to retrieve from
2584
+ * @param start The starting offset
2585
+ * @param end The ending offset
2586
+ * @returns Promise that resolves with the substring value
2587
+ *
2588
+ * @deprecated Use {@link getrange} instead. SUBSTR is a deprecated Redis command.
2589
+ */
2590
+ substr(key: RedisClient.KeyLike, start: number, end: number): Promise<string>;
2591
+
2592
+ /**
2593
+ * Overwrite part of a string at key starting at the specified offset
2594
+ * @param key The key to modify
2595
+ * @param offset The offset at which to start overwriting (zero-based)
2596
+ * @param value The string value to write at the offset
2597
+ * @returns Promise that resolves with the length of the string after modification
2598
+ */
2599
+ setrange(key: RedisClient.KeyLike, offset: number, value: RedisClient.KeyLike): Promise<number>;
2600
+
596
2601
  /**
597
2602
  * Return a serialized version of the value stored at the specified key
598
2603
  * @param key The key to dump
@@ -812,6 +2817,526 @@ declare module "bun" {
812
2817
  * This will open up a new connection to the Redis server.
813
2818
  */
814
2819
  duplicate(): Promise<RedisClient>;
2820
+
2821
+ /**
2822
+ * Copy the value stored at the source key to the destination key
2823
+ *
2824
+ * By default, the destination key is created in the logical database used
2825
+ * by the connection. The REPLACE option removes the destination key before
2826
+ * copying the value to it.
2827
+ *
2828
+ * @param source The source key to copy from
2829
+ * @param destination The destination key to copy to
2830
+ * @returns Promise that resolves with 1 if the key was copied, 0 if not
2831
+ *
2832
+ * @example
2833
+ * ```ts
2834
+ * await redis.set("mykey", "Hello");
2835
+ * await redis.copy("mykey", "myotherkey");
2836
+ * console.log(await redis.get("myotherkey")); // "Hello"
2837
+ * ```
2838
+ */
2839
+ copy(source: RedisClient.KeyLike, destination: RedisClient.KeyLike): Promise<number>;
2840
+
2841
+ /**
2842
+ * Copy the value stored at the source key to the destination key, optionally replacing it
2843
+ *
2844
+ * The REPLACE option removes the destination key before copying the value to it.
2845
+ *
2846
+ * @param source The source key to copy from
2847
+ * @param destination The destination key to copy to
2848
+ * @param replace "REPLACE" - Remove the destination key before copying
2849
+ * @returns Promise that resolves with 1 if the key was copied, 0 if not
2850
+ *
2851
+ * @example
2852
+ * ```ts
2853
+ * await redis.set("mykey", "Hello");
2854
+ * await redis.set("myotherkey", "World");
2855
+ * await redis.copy("mykey", "myotherkey", "REPLACE");
2856
+ * console.log(await redis.get("myotherkey")); // "Hello"
2857
+ * ```
2858
+ */
2859
+ copy(source: RedisClient.KeyLike, destination: RedisClient.KeyLike, replace: "REPLACE"): Promise<number>;
2860
+
2861
+ /**
2862
+ * Asynchronously delete one or more keys
2863
+ *
2864
+ * This command is very similar to DEL: it removes the specified keys.
2865
+ * Just like DEL a key is ignored if it does not exist. However, the
2866
+ * command performs the actual memory reclaiming in a different thread, so
2867
+ * it is not blocking, while DEL is. This is particularly useful when
2868
+ * deleting large values or large numbers of keys.
2869
+ *
2870
+ * @param keys The keys to delete
2871
+ * @returns Promise that resolves with the number of keys that were unlinked
2872
+ *
2873
+ * @example
2874
+ * ```ts
2875
+ * await redis.set("key1", "Hello");
2876
+ * await redis.set("key2", "World");
2877
+ * const count = await redis.unlink("key1", "key2", "key3");
2878
+ * console.log(count); // 2
2879
+ * ```
2880
+ */
2881
+ unlink(...keys: RedisClient.KeyLike[]): Promise<number>;
2882
+
2883
+ /**
2884
+ * Alters the last access time of one or more keys
2885
+ *
2886
+ * A key is ignored if it does not exist. The command returns the number
2887
+ * of keys that were touched.
2888
+ *
2889
+ * This command is useful in conjunction with maxmemory-policy
2890
+ * allkeys-lru / volatile-lru to change the last access time of keys for
2891
+ * eviction purposes.
2892
+ *
2893
+ * @param keys One or more keys to touch
2894
+ * @returns Promise that resolves with the number of keys that were touched
2895
+ *
2896
+ * @example
2897
+ * ```ts
2898
+ * await redis.set("key1", "Hello");
2899
+ * await redis.set("key2", "World");
2900
+ * const touched = await redis.touch("key1", "key2", "key3");
2901
+ * console.log(touched); // 2 (key3 doesn't exist)
2902
+ * ```
2903
+ */
2904
+ touch(...keys: RedisClient.KeyLike[]): Promise<number>;
2905
+
2906
+ /**
2907
+ * Rename a key to a new key
2908
+ *
2909
+ * Renames key to newkey. If newkey already exists, it is overwritten. If
2910
+ * key does not exist, an error is returned.
2911
+ *
2912
+ * @param key The key to rename
2913
+ * @param newkey The new key name
2914
+ * @returns Promise that resolves with "OK" on success
2915
+ *
2916
+ * @example
2917
+ * ```ts
2918
+ * await redis.set("mykey", "Hello");
2919
+ * await redis.rename("mykey", "myotherkey");
2920
+ * const value = await redis.get("myotherkey"); // "Hello"
2921
+ * const oldValue = await redis.get("mykey"); // null
2922
+ * ```
2923
+ */
2924
+ rename(key: RedisClient.KeyLike, newkey: RedisClient.KeyLike): Promise<"OK">;
2925
+
2926
+ /**
2927
+ * Rename a key to a new key only if the new key does not exist
2928
+ *
2929
+ * Renames key to newkey only if newkey does not yet exist. If key does not
2930
+ * exist, an error is returned.
2931
+ *
2932
+ * @param key The key to rename
2933
+ * @param newkey The new key name
2934
+ * @returns Promise that resolves with 1 if the key was renamed, 0 if newkey already exists
2935
+ *
2936
+ * @example
2937
+ * ```ts
2938
+ * await redis.set("mykey", "Hello");
2939
+ * await redis.renamenx("mykey", "myotherkey"); // Returns 1
2940
+ * await redis.set("mykey2", "World");
2941
+ * await redis.renamenx("mykey2", "myotherkey"); // Returns 0 (myotherkey exists)
2942
+ * ```
2943
+ */
2944
+ renamenx(key: RedisClient.KeyLike, newkey: RedisClient.KeyLike): Promise<number>;
2945
+
2946
+ /**
2947
+ * Compute the difference between sorted sets with scores
2948
+ *
2949
+ * @param numkeys The number of sorted set keys
2950
+ * @param keys The sorted set keys followed by "WITHSCORES"
2951
+ * @returns Promise that resolves with an array of [member, score] pairs
2952
+ *
2953
+ * @example
2954
+ * ```ts
2955
+ * await redis.send("ZADD", ["zset1", "1", "one", "2", "two", "3", "three"]);
2956
+ * await redis.send("ZADD", ["zset2", "1", "one", "2", "two"]);
2957
+ * const diff = await redis.zdiff(2, "zset1", "zset2", "WITHSCORES");
2958
+ * console.log(diff); // ["three", "3"]
2959
+ * ```
2960
+ */
2961
+ zdiff(
2962
+ numkeys: number,
2963
+ ...args: [...keys: RedisClient.KeyLike[], withscores: "WITHSCORES"]
2964
+ ): Promise<[string, number][]>;
2965
+
2966
+ /**
2967
+ * Compute the difference between the first sorted set and all successive sorted sets
2968
+ *
2969
+ * Returns the members of the sorted set resulting from the difference between the first
2970
+ * sorted set and all the successive sorted sets. The first key is the only one used to
2971
+ * compute the members of the difference.
2972
+ *
2973
+ * @param numkeys The number of sorted set keys
2974
+ * @param keys The sorted set keys to compare
2975
+ * @returns Promise that resolves with an array of members
2976
+ *
2977
+ * @example
2978
+ * ```ts
2979
+ * await redis.send("ZADD", ["zset1", "1", "one", "2", "two", "3", "three"]);
2980
+ * await redis.send("ZADD", ["zset2", "1", "one", "2", "two"]);
2981
+ * const diff = await redis.zdiff(2, "zset1", "zset2");
2982
+ * console.log(diff); // ["three"]
2983
+ * ```
2984
+ */
2985
+ zdiff(numkeys: number, ...keys: RedisClient.KeyLike[]): Promise<string[]>;
2986
+
2987
+ /**
2988
+ * Compute the difference between sorted sets and store the result
2989
+ *
2990
+ * Computes the difference between the first and all successive sorted sets given by the
2991
+ * specified keys and stores the result in destination. Keys that do not exist are
2992
+ * considered to be empty sets.
2993
+ *
2994
+ * @param destination The destination key to store the result
2995
+ * @param numkeys The number of input sorted set keys
2996
+ * @param keys The sorted set keys to compare
2997
+ * @returns Promise that resolves with the number of elements in the resulting sorted set
2998
+ *
2999
+ * @example
3000
+ * ```ts
3001
+ * await redis.send("ZADD", ["zset1", "1", "one", "2", "two", "3", "three"]);
3002
+ * await redis.send("ZADD", ["zset2", "1", "one"]);
3003
+ * const count = await redis.zdiffstore("out", 2, "zset1", "zset2");
3004
+ * console.log(count); // 2 (two, three)
3005
+ * ```
3006
+ */
3007
+ zdiffstore(destination: RedisClient.KeyLike, numkeys: number, ...keys: RedisClient.KeyLike[]): Promise<number>;
3008
+
3009
+ /**
3010
+ * Compute the intersection of multiple sorted sets
3011
+ *
3012
+ * Returns the members of the set resulting from the intersection of all the given sorted sets.
3013
+ * Keys that do not exist are considered to be empty sets.
3014
+ *
3015
+ * By default, the resulting score of each member is the sum of its scores in the sorted sets where it exists.
3016
+ *
3017
+ * Options:
3018
+ * - WEIGHTS: Multiply the score of each member in the corresponding sorted set by the given weight before aggregation
3019
+ * - AGGREGATE SUM|MIN|MAX: Specify how the scores are aggregated (default: SUM)
3020
+ * - WITHSCORES: Return the scores along with the members
3021
+ *
3022
+ * @param numkeys The number of input keys (sorted sets)
3023
+ * @param keys The sorted set keys to intersect
3024
+ * @returns Promise that resolves with an array of members (or [member, score] pairs if WITHSCORES)
3025
+ *
3026
+ * @example
3027
+ * ```ts
3028
+ * // Set up sorted sets
3029
+ * await redis.zadd("zset1", "1", "a", "2", "b", "3", "c");
3030
+ * await redis.zadd("zset2", "1", "b", "2", "c", "3", "d");
3031
+ *
3032
+ * // Basic intersection - returns members that exist in all sets
3033
+ * const result1 = await redis.zinter(2, "zset1", "zset2");
3034
+ * // Returns: ["b", "c"]
3035
+ *
3036
+ * // With scores (sum by default)
3037
+ * const result2 = await redis.zinter(2, "zset1", "zset2", "WITHSCORES");
3038
+ * // Returns: ["b", "3", "c", "5"] (b: 2+1=3, c: 3+2=5)
3039
+ *
3040
+ * // With weights
3041
+ * const result3 = await redis.zinter(2, "zset1", "zset2", "WEIGHTS", "2", "3", "WITHSCORES");
3042
+ * // Returns: ["b", "7", "c", "12"] (b: 2*2+1*3=7, c: 3*2+2*3=12)
3043
+ *
3044
+ * // With MIN aggregation
3045
+ * const result4 = await redis.zinter(2, "zset1", "zset2", "AGGREGATE", "MIN", "WITHSCORES");
3046
+ * // Returns: ["b", "1", "c", "2"] (minimum scores)
3047
+ * ```
3048
+ */
3049
+ zinter(
3050
+ numkeys: number,
3051
+ ...args: [...args: (string | number)[], withscores: "WITHSCORES"]
3052
+ ): Promise<[string, number][]>;
3053
+
3054
+ /**
3055
+ * Compute the intersection of multiple sorted sets
3056
+ *
3057
+ * Returns the members of the set resulting from the intersection of all the given sorted sets.
3058
+ * Keys that do not exist are considered to be empty sets.
3059
+ *
3060
+ * By default, the resulting score of each member is the sum of its scores in the sorted sets where it exists.
3061
+ *
3062
+ * Options:
3063
+ * - WEIGHTS: Multiply the score of each member in the corresponding sorted set by the given weight before aggregation
3064
+ * - AGGREGATE SUM|MIN|MAX: Specify how the scores are aggregated (default: SUM)
3065
+ * - WITHSCORES: Return the scores along with the members
3066
+ *
3067
+ * @param numkeys The number of input keys (sorted sets)
3068
+ * @param keys The sorted set keys to intersect
3069
+ * @returns Promise that resolves with an array of members (or [member, score] pairs if WITHSCORES)
3070
+ *
3071
+ * @example
3072
+ * ```ts
3073
+ * // Set up sorted sets
3074
+ * await redis.zadd("zset1", "1", "a", "2", "b", "3", "c");
3075
+ * await redis.zadd("zset2", "1", "b", "2", "c", "3", "d");
3076
+ *
3077
+ * // Basic intersection - returns members that exist in all sets
3078
+ * const result1 = await redis.zinter(2, "zset1", "zset2");
3079
+ * // Returns: ["b", "c"]
3080
+ *
3081
+ * // With scores (sum by default)
3082
+ * const result2 = await redis.zinter(2, "zset1", "zset2", "WITHSCORES");
3083
+ * // Returns: ["b", "3", "c", "5"] (b: 2+1=3, c: 3+2=5)
3084
+ *
3085
+ * // With weights
3086
+ * const result3 = await redis.zinter(2, "zset1", "zset2", "WEIGHTS", "2", "3", "WITHSCORES");
3087
+ * // Returns: ["b", "7", "c", "12"] (b: 2*2+1*3=7, c: 3*2+2*3=12)
3088
+ *
3089
+ * // With MIN aggregation
3090
+ * const result4 = await redis.zinter(2, "zset1", "zset2", "AGGREGATE", "MIN", "WITHSCORES");
3091
+ * // Returns: ["b", "1", "c", "2"] (minimum scores)
3092
+ * ```
3093
+ */
3094
+ zinter(numkeys: number, ...args: (string | number)[]): Promise<string[]>;
3095
+
3096
+ /**
3097
+ * Count the number of members in the intersection of multiple sorted sets
3098
+ *
3099
+ * Computes the cardinality of the intersection of the sorted sets at the specified keys.
3100
+ * The intersection includes only elements that exist in all of the given sorted sets.
3101
+ *
3102
+ * When a LIMIT is provided, the command stops counting once the limit is reached, which
3103
+ * is useful for performance when you only need to know if the cardinality exceeds a
3104
+ * certain threshold.
3105
+ *
3106
+ * @param numkeys The number of sorted set keys
3107
+ * @param keys The sorted set keys to intersect
3108
+ * @returns Promise that resolves with the number of elements in the intersection
3109
+ *
3110
+ * @example
3111
+ * ```ts
3112
+ * await redis.send("ZADD", ["zset1", "1", "one", "2", "two", "3", "three"]);
3113
+ * await redis.send("ZADD", ["zset2", "1", "one", "2", "two", "4", "four"]);
3114
+ * const count = await redis.zintercard(2, "zset1", "zset2");
3115
+ * console.log(count); // 2 (one, two)
3116
+ * ```
3117
+ */
3118
+ zintercard(numkeys: number, ...keys: RedisClient.KeyLike[]): Promise<number>;
3119
+
3120
+ /**
3121
+ * Count the number of members in the intersection with a limit
3122
+ *
3123
+ * @param numkeys The number of sorted set keys
3124
+ * @param keys The sorted set keys followed by "LIMIT" and limit value
3125
+ * @returns Promise that resolves with the number of elements (up to limit)
3126
+ *
3127
+ * @example
3128
+ * ```ts
3129
+ * await redis.send("ZADD", ["zset1", "1", "a", "2", "b", "3", "c"]);
3130
+ * await redis.send("ZADD", ["zset2", "1", "a", "2", "b", "3", "c"]);
3131
+ * const count = await redis.zintercard(2, "zset1", "zset2", "LIMIT", 2);
3132
+ * console.log(count); // 2 (stopped at limit)
3133
+ * ```
3134
+ */
3135
+ zintercard(numkeys: number, ...args: (RedisClient.KeyLike | "LIMIT" | number)[]): Promise<number>;
3136
+
3137
+ /**
3138
+ * Compute the intersection of multiple sorted sets and store in destination
3139
+ *
3140
+ * This command is similar to ZINTER, but instead of returning the result, it stores it in the destination key.
3141
+ * If the destination key already exists, it is overwritten.
3142
+ *
3143
+ * Options:
3144
+ * - WEIGHTS: Multiply the score of each member in the corresponding sorted set by the given weight before aggregation
3145
+ * - AGGREGATE SUM|MIN|MAX: Specify how the scores are aggregated (default: SUM)
3146
+ *
3147
+ * @param destination The destination key to store the result
3148
+ * @param numkeys The number of input keys (sorted sets)
3149
+ * @param keys The sorted set keys to intersect and optional WEIGHTS/AGGREGATE options
3150
+ * @returns Promise that resolves with the number of elements in the resulting sorted set
3151
+ *
3152
+ * @example
3153
+ * ```ts
3154
+ * // Set up sorted sets
3155
+ * await redis.zadd("zset1", "1", "a", "2", "b", "3", "c");
3156
+ * await redis.zadd("zset2", "1", "b", "2", "c", "3", "d");
3157
+ *
3158
+ * // Basic intersection store
3159
+ * const count1 = await redis.zinterstore("out", 2, "zset1", "zset2");
3160
+ * // Returns: 2 (stored "b" and "c" in "out")
3161
+ *
3162
+ * // With weights
3163
+ * const count2 = await redis.zinterstore("out2", 2, "zset1", "zset2", "WEIGHTS", "2", "3");
3164
+ * // Returns: 2
3165
+ *
3166
+ * // With MAX aggregation
3167
+ * const count3 = await redis.zinterstore("out3", 2, "zset1", "zset2", "AGGREGATE", "MAX");
3168
+ * // Returns: 2 (stores maximum scores)
3169
+ * ```
3170
+ */
3171
+ zinterstore(destination: RedisClient.KeyLike, numkeys: number, ...args: (string | number)[]): Promise<number>;
3172
+
3173
+ /**
3174
+ * Compute the union of multiple sorted sets
3175
+ *
3176
+ * Returns the union of the sorted sets given by the specified keys.
3177
+ * For every element that appears in at least one of the input sorted sets, the output will contain that element.
3178
+ *
3179
+ * Options:
3180
+ * - WEIGHTS: Multiply the score of each member in the corresponding sorted set by the given weight before aggregation
3181
+ * - AGGREGATE SUM|MIN|MAX: Specify how the scores are aggregated (default: SUM)
3182
+ * - WITHSCORES: Include scores in the result
3183
+ *
3184
+ * @param numkeys The number of input keys (sorted sets)
3185
+ * @param keys The sorted set keys to union and optional WEIGHTS/AGGREGATE/WITHSCORES options
3186
+ * @returns Promise that resolves with an array of members (or members with scores if WITHSCORES is used)
3187
+ *
3188
+ * @example
3189
+ * ```ts
3190
+ * // Set up sorted sets
3191
+ * await redis.zadd("zset1", "1", "a", "2", "b", "3", "c");
3192
+ * await redis.zadd("zset2", "4", "b", "5", "c", "6", "d");
3193
+ *
3194
+ * // Basic union
3195
+ * const members1 = await redis.zunion(2, "zset1", "zset2");
3196
+ * // Returns: ["a", "b", "c", "d"]
3197
+ *
3198
+ * // With weights
3199
+ * const members2 = await redis.zunion(2, "zset1", "zset2", "WEIGHTS", "2", "3");
3200
+ * // Returns: ["a", "b", "c", "d"] with calculated scores
3201
+ *
3202
+ * // With MIN aggregation
3203
+ * const members3 = await redis.zunion(2, "zset1", "zset2", "AGGREGATE", "MIN");
3204
+ * // Returns: ["a", "b", "c", "d"] with minimum scores
3205
+ *
3206
+ * // With scores
3207
+ * const withScores = await redis.zunion(2, "zset1", "zset2", "WITHSCORES");
3208
+ * // Returns: ["a", "1", "b", "2", "c", "3", "d", "6"] (alternating member and score)
3209
+ * ```
3210
+ */
3211
+ zunion(
3212
+ numkeys: number,
3213
+ ...args: [...args: (string | number)[], withscores: "WITHSCORES"]
3214
+ ): Promise<[string, number][]>;
3215
+
3216
+ /**
3217
+ * Compute the union of multiple sorted sets
3218
+ *
3219
+ * Returns the union of the sorted sets given by the specified keys.
3220
+ * For every element that appears in at least one of the input sorted sets, the output will contain that element.
3221
+ *
3222
+ * Options:
3223
+ * - WEIGHTS: Multiply the score of each member in the corresponding sorted set by the given weight before aggregation
3224
+ * - AGGREGATE SUM|MIN|MAX: Specify how the scores are aggregated (default: SUM)
3225
+ * - WITHSCORES: Include scores in the result
3226
+ *
3227
+ * @param numkeys The number of input keys (sorted sets)
3228
+ * @param keys The sorted set keys to union and optional WEIGHTS/AGGREGATE/WITHSCORES options
3229
+ * @returns Promise that resolves with an array of members (or members with scores if WITHSCORES is used)
3230
+ *
3231
+ * @example
3232
+ * ```ts
3233
+ * // Set up sorted sets
3234
+ * await redis.zadd("zset1", "1", "a", "2", "b", "3", "c");
3235
+ * await redis.zadd("zset2", "4", "b", "5", "c", "6", "d");
3236
+ *
3237
+ * // Basic union
3238
+ * const members1 = await redis.zunion(2, "zset1", "zset2");
3239
+ * // Returns: ["a", "b", "c", "d"]
3240
+ *
3241
+ * // With weights
3242
+ * const members2 = await redis.zunion(2, "zset1", "zset2", "WEIGHTS", "2", "3");
3243
+ * // Returns: ["a", "b", "c", "d"] with calculated scores
3244
+ *
3245
+ * // With MIN aggregation
3246
+ * const members3 = await redis.zunion(2, "zset1", "zset2", "AGGREGATE", "MIN");
3247
+ * // Returns: ["a", "b", "c", "d"] with minimum scores
3248
+ *
3249
+ * // With scores
3250
+ * const withScores = await redis.zunion(2, "zset1", "zset2", "WITHSCORES");
3251
+ * // Returns: ["a", "1", "b", "2", "c", "3", "d", "6"] (alternating member and score)
3252
+ * ```
3253
+ */
3254
+ zunion(numkeys: number, ...args: (string | number)[]): Promise<string[]>;
3255
+
3256
+ /**
3257
+ * Compute the union of multiple sorted sets and store in destination
3258
+ *
3259
+ * This command is similar to ZUNION, but instead of returning the result, it stores it in the destination key.
3260
+ * If the destination key already exists, it is overwritten.
3261
+ *
3262
+ * Options:
3263
+ * - WEIGHTS: Multiply the score of each member in the corresponding sorted set by the given weight before aggregation
3264
+ * - AGGREGATE SUM|MIN|MAX: Specify how the scores are aggregated (default: SUM)
3265
+ *
3266
+ * @param destination The destination key to store the result
3267
+ * @param numkeys The number of input keys (sorted sets)
3268
+ * @param keys The sorted set keys to union and optional WEIGHTS/AGGREGATE options
3269
+ * @returns Promise that resolves with the number of elements in the resulting sorted set
3270
+ *
3271
+ * @example
3272
+ * ```ts
3273
+ * // Set up sorted sets
3274
+ * await redis.zadd("zset1", "1", "a", "2", "b", "3", "c");
3275
+ * await redis.zadd("zset2", "4", "b", "5", "c", "6", "d");
3276
+ *
3277
+ * // Basic union store
3278
+ * const count1 = await redis.zunionstore("out", 2, "zset1", "zset2");
3279
+ * // Returns: 4 (stored "a", "b", "c", "d" in "out")
3280
+ *
3281
+ * // With weights
3282
+ * const count2 = await redis.zunionstore("out2", 2, "zset1", "zset2", "WEIGHTS", "2", "3");
3283
+ * // Returns: 4
3284
+ *
3285
+ * // With MAX aggregation
3286
+ * const count3 = await redis.zunionstore("out3", 2, "zset1", "zset2", "AGGREGATE", "MAX");
3287
+ * // Returns: 4 (stores maximum scores)
3288
+ * ```
3289
+ */
3290
+ zunionstore(destination: RedisClient.KeyLike, numkeys: number, ...args: (string | number)[]): Promise<number>;
3291
+
3292
+ /**
3293
+ * Remove and return members with scores from one or more sorted sets.
3294
+ * Pops from the first non-empty sorted set.
3295
+ *
3296
+ * @example
3297
+ * ```ts
3298
+ * // Pop lowest score from one set
3299
+ * const result1 = await redis.zmpop(1, "myzset", "MIN");
3300
+ * // Returns: ["myzset", [["member1", 1]]]
3301
+ *
3302
+ * // Pop highest score from multiple sets
3303
+ * const result2 = await redis.zmpop(2, "zset1", "zset2", "MAX");
3304
+ * // Returns: ["zset1", [["member5", 5]]] (pops from first non-empty)
3305
+ *
3306
+ * // Pop multiple members
3307
+ * const result3 = await redis.zmpop(1, "myzset", "MIN", "COUNT", 3);
3308
+ * // Returns: ["myzset", [["member1", 1], ["member2", 2], ["member3", 3]]]
3309
+ *
3310
+ * // Empty set returns null
3311
+ * const result4 = await redis.zmpop(1, "emptyset", "MIN");
3312
+ * // Returns: null
3313
+ * ```
3314
+ */
3315
+ zmpop(numkeys: number, ...args: (string | number)[]): Promise<[string, [string, number][]] | null>;
3316
+
3317
+ /**
3318
+ * Blocking version of ZMPOP. Blocks until a member is available or timeout expires.
3319
+ *
3320
+ * @example
3321
+ * ```ts
3322
+ * // Block for 5 seconds waiting for a member
3323
+ * const result1 = await redis.bzmpop(5, 1, "myzset", "MIN");
3324
+ * // Returns: ["myzset", [["member1", 1]]] or null if timeout
3325
+ *
3326
+ * // Block indefinitely (timeout 0)
3327
+ * const result2 = await redis.bzmpop(0, 2, "zset1", "zset2", "MAX");
3328
+ * // Returns: ["zset1", [["member5", 5]]]
3329
+ *
3330
+ * // Block with COUNT option
3331
+ * const result3 = await redis.bzmpop(1, 1, "myzset", "MIN", "COUNT", 2);
3332
+ * // Returns: ["myzset", [["member1", 1], ["member2", 2]]] or null if timeout
3333
+ * ```
3334
+ */
3335
+ bzmpop(
3336
+ timeout: number,
3337
+ numkeys: number,
3338
+ ...args: (string | number)[]
3339
+ ): Promise<[string, [string, number][]] | null>;
815
3340
  }
816
3341
 
817
3342
  /**