@upstash/redis 1.37.0 → 1.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3911,6 +3911,102 @@ var Pipeline = class {
3911
3911
  };
3912
3912
 
3913
3913
  // pkg/auto-pipeline.ts
3914
+ var MAX_PIPELINE_SIZE = 1e3;
3915
+ var READ_COMMANDS = /* @__PURE__ */ new Set([
3916
+ // String
3917
+ "get",
3918
+ "getrange",
3919
+ "mget",
3920
+ "strlen",
3921
+ // Bit
3922
+ "bitcount",
3923
+ "bitpos",
3924
+ "getbit",
3925
+ // Hash
3926
+ "hexists",
3927
+ "hget",
3928
+ "hgetall",
3929
+ "hkeys",
3930
+ "hlen",
3931
+ "hmget",
3932
+ "hrandfield",
3933
+ "hscan",
3934
+ "hstrlen",
3935
+ "httl",
3936
+ "hvals",
3937
+ "hexpiretime",
3938
+ "hpexpiretime",
3939
+ "hpttl",
3940
+ // List
3941
+ "lindex",
3942
+ "llen",
3943
+ "lpos",
3944
+ "lrange",
3945
+ // Set
3946
+ "scard",
3947
+ "sdiff",
3948
+ "sinter",
3949
+ "sintercard",
3950
+ "sismember",
3951
+ "smembers",
3952
+ "smismember",
3953
+ "srandmember",
3954
+ "sscan",
3955
+ "sunion",
3956
+ // Sorted set
3957
+ "zcard",
3958
+ "zcount",
3959
+ "zlexcount",
3960
+ "zmscore",
3961
+ "zrange",
3962
+ "zrank",
3963
+ "zrevrank",
3964
+ "zscan",
3965
+ "zscore",
3966
+ "zunion",
3967
+ // Key metadata
3968
+ "exists",
3969
+ "type",
3970
+ "ttl",
3971
+ "pttl",
3972
+ "randomkey",
3973
+ "touch",
3974
+ // HyperLogLog
3975
+ "pfcount",
3976
+ // Stream
3977
+ "xinfo",
3978
+ "xlen",
3979
+ "xpending",
3980
+ "xrange",
3981
+ "xread",
3982
+ "xrevrange",
3983
+ // Geo
3984
+ "geodist",
3985
+ "geohash",
3986
+ "geopos",
3987
+ "geosearch",
3988
+ // Script / eval
3989
+ "scriptExists",
3990
+ "evalRo",
3991
+ "evalshaRo",
3992
+ // Utility
3993
+ "dbsize",
3994
+ "echo",
3995
+ "ping",
3996
+ "time",
3997
+ "scan",
3998
+ "keys",
3999
+ // JSON namespace
4000
+ "arrindex",
4001
+ "arrlen",
4002
+ "objkeys",
4003
+ "objlen",
4004
+ "resp",
4005
+ // Functions namespace
4006
+ "list",
4007
+ "stats",
4008
+ "callRo"
4009
+ ]);
3914
4010
  var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
3915
4011
  "scan",
3916
4012
  "keys",
@@ -3957,7 +4053,8 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
3957
4053
  const isFunction = typeof targetFunction === "function";
3958
4054
  if (isFunction) {
3959
4055
  return (...args) => {
3960
- return redis2.autoPipelineExecutor.withAutoPipeline((pipeline2) => {
4056
+ const commandMode = READ_COMMANDS.has(command) ? "read" : "write";
4057
+ return redis2.autoPipelineExecutor.withAutoPipeline(commandMode, (pipeline2) => {
3961
4058
  const targetFunction2 = namespace === "json" ? pipeline2.json[command] : namespace === "functions" ? pipeline2.functions[command] : pipeline2[command];
3962
4059
  targetFunction2(...args);
3963
4060
  });
@@ -3969,8 +4066,10 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
3969
4066
  }
3970
4067
  var AutoPipelineExecutor = class {
3971
4068
  pipelinePromises = /* @__PURE__ */ new WeakMap();
3972
- activePipeline = null;
3973
- indexInCurrentPipeline = 0;
4069
+ activeReadPipeline = null;
4070
+ activeWritePipeline = null;
4071
+ readIndex = 0;
4072
+ writeIndex = 0;
3974
4073
  redis;
3975
4074
  pipeline;
3976
4075
  // only to make sure that proxy can work
@@ -3980,20 +4079,37 @@ var AutoPipelineExecutor = class {
3980
4079
  this.redis = redis;
3981
4080
  this.pipeline = redis.pipeline();
3982
4081
  }
3983
- async withAutoPipeline(executeWithPipeline) {
3984
- const pipeline = this.activePipeline ?? this.redis.pipeline();
3985
- if (!this.activePipeline) {
3986
- this.activePipeline = pipeline;
3987
- this.indexInCurrentPipeline = 0;
4082
+ async withAutoPipeline(commandMode, executeWithPipeline) {
4083
+ const isRead = commandMode === "read";
4084
+ const activePipeline = isRead ? this.activeReadPipeline : this.activeWritePipeline;
4085
+ const pipeline = activePipeline ?? this.redis.pipeline();
4086
+ if (!activePipeline) {
4087
+ if (isRead) {
4088
+ this.activeReadPipeline = pipeline;
4089
+ this.readIndex = 0;
4090
+ } else {
4091
+ this.activeWritePipeline = pipeline;
4092
+ this.writeIndex = 0;
4093
+ }
3988
4094
  }
3989
- const index = this.indexInCurrentPipeline++;
4095
+ const index = isRead ? this.readIndex++ : this.writeIndex++;
3990
4096
  executeWithPipeline(pipeline);
4097
+ if (isRead && this.readIndex >= MAX_PIPELINE_SIZE) {
4098
+ this.activeReadPipeline = null;
4099
+ } else if (!isRead && this.writeIndex >= MAX_PIPELINE_SIZE) {
4100
+ this.activeWritePipeline = null;
4101
+ }
3991
4102
  const pipelineDone = this.deferExecution().then(() => {
3992
4103
  if (!this.pipelinePromises.has(pipeline)) {
3993
4104
  const pipelinePromise = pipeline.exec({ keepErrors: true });
3994
4105
  this.pipelineCounter += 1;
3995
4106
  this.pipelinePromises.set(pipeline, pipelinePromise);
3996
- this.activePipeline = null;
4107
+ if (this.activeReadPipeline === pipeline) {
4108
+ this.activeReadPipeline = null;
4109
+ }
4110
+ if (this.activeWritePipeline === pipeline) {
4111
+ this.activeWritePipeline = null;
4112
+ }
3997
4113
  }
3998
4114
  return this.pipelinePromises.get(pipeline);
3999
4115
  });
@@ -5305,7 +5421,7 @@ var Redis = class {
5305
5421
  };
5306
5422
 
5307
5423
  // version.ts
5308
- var VERSION = "v1.30.2";
5424
+ var VERSION = "v1.38.0";
5309
5425
 
5310
5426
  export {
5311
5427
  error_exports,
package/cloudflare.js CHANGED
@@ -341,6 +341,102 @@ function merge(obj, key, value) {
341
341
  }
342
342
 
343
343
  // pkg/auto-pipeline.ts
344
+ var MAX_PIPELINE_SIZE = 1e3;
345
+ var READ_COMMANDS = /* @__PURE__ */ new Set([
346
+ // String
347
+ "get",
348
+ "getrange",
349
+ "mget",
350
+ "strlen",
351
+ // Bit
352
+ "bitcount",
353
+ "bitpos",
354
+ "getbit",
355
+ // Hash
356
+ "hexists",
357
+ "hget",
358
+ "hgetall",
359
+ "hkeys",
360
+ "hlen",
361
+ "hmget",
362
+ "hrandfield",
363
+ "hscan",
364
+ "hstrlen",
365
+ "httl",
366
+ "hvals",
367
+ "hexpiretime",
368
+ "hpexpiretime",
369
+ "hpttl",
370
+ // List
371
+ "lindex",
372
+ "llen",
373
+ "lpos",
374
+ "lrange",
375
+ // Set
376
+ "scard",
377
+ "sdiff",
378
+ "sinter",
379
+ "sintercard",
380
+ "sismember",
381
+ "smembers",
382
+ "smismember",
383
+ "srandmember",
384
+ "sscan",
385
+ "sunion",
386
+ // Sorted set
387
+ "zcard",
388
+ "zcount",
389
+ "zlexcount",
390
+ "zmscore",
391
+ "zrange",
392
+ "zrank",
393
+ "zrevrank",
394
+ "zscan",
395
+ "zscore",
396
+ "zunion",
397
+ // Key metadata
398
+ "exists",
399
+ "type",
400
+ "ttl",
401
+ "pttl",
402
+ "randomkey",
403
+ "touch",
404
+ // HyperLogLog
405
+ "pfcount",
406
+ // Stream
407
+ "xinfo",
408
+ "xlen",
409
+ "xpending",
410
+ "xrange",
411
+ "xread",
412
+ "xrevrange",
413
+ // Geo
414
+ "geodist",
415
+ "geohash",
416
+ "geopos",
417
+ "geosearch",
418
+ // Script / eval
419
+ "scriptExists",
420
+ "evalRo",
421
+ "evalshaRo",
422
+ // Utility
423
+ "dbsize",
424
+ "echo",
425
+ "ping",
426
+ "time",
427
+ "scan",
428
+ "keys",
429
+ // JSON namespace
430
+ "arrindex",
431
+ "arrlen",
432
+ "objkeys",
433
+ "objlen",
434
+ "resp",
435
+ // Functions namespace
436
+ "list",
437
+ "stats",
438
+ "callRo"
439
+ ]);
344
440
  var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
345
441
  "scan",
346
442
  "keys",
@@ -387,7 +483,8 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
387
483
  const isFunction = typeof targetFunction === "function";
388
484
  if (isFunction) {
389
485
  return (...args) => {
390
- return redis2.autoPipelineExecutor.withAutoPipeline((pipeline2) => {
486
+ const commandMode = READ_COMMANDS.has(command) ? "read" : "write";
487
+ return redis2.autoPipelineExecutor.withAutoPipeline(commandMode, (pipeline2) => {
391
488
  const targetFunction2 = namespace === "json" ? pipeline2.json[command] : namespace === "functions" ? pipeline2.functions[command] : pipeline2[command];
392
489
  targetFunction2(...args);
393
490
  });
@@ -399,8 +496,10 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
399
496
  }
400
497
  var AutoPipelineExecutor = class {
401
498
  pipelinePromises = /* @__PURE__ */ new WeakMap();
402
- activePipeline = null;
403
- indexInCurrentPipeline = 0;
499
+ activeReadPipeline = null;
500
+ activeWritePipeline = null;
501
+ readIndex = 0;
502
+ writeIndex = 0;
404
503
  redis;
405
504
  pipeline;
406
505
  // only to make sure that proxy can work
@@ -410,20 +509,37 @@ var AutoPipelineExecutor = class {
410
509
  this.redis = redis;
411
510
  this.pipeline = redis.pipeline();
412
511
  }
413
- async withAutoPipeline(executeWithPipeline) {
414
- const pipeline = this.activePipeline ?? this.redis.pipeline();
415
- if (!this.activePipeline) {
416
- this.activePipeline = pipeline;
417
- this.indexInCurrentPipeline = 0;
512
+ async withAutoPipeline(commandMode, executeWithPipeline) {
513
+ const isRead = commandMode === "read";
514
+ const activePipeline = isRead ? this.activeReadPipeline : this.activeWritePipeline;
515
+ const pipeline = activePipeline ?? this.redis.pipeline();
516
+ if (!activePipeline) {
517
+ if (isRead) {
518
+ this.activeReadPipeline = pipeline;
519
+ this.readIndex = 0;
520
+ } else {
521
+ this.activeWritePipeline = pipeline;
522
+ this.writeIndex = 0;
523
+ }
418
524
  }
419
- const index = this.indexInCurrentPipeline++;
525
+ const index = isRead ? this.readIndex++ : this.writeIndex++;
420
526
  executeWithPipeline(pipeline);
527
+ if (isRead && this.readIndex >= MAX_PIPELINE_SIZE) {
528
+ this.activeReadPipeline = null;
529
+ } else if (!isRead && this.writeIndex >= MAX_PIPELINE_SIZE) {
530
+ this.activeWritePipeline = null;
531
+ }
421
532
  const pipelineDone = this.deferExecution().then(() => {
422
533
  if (!this.pipelinePromises.has(pipeline)) {
423
534
  const pipelinePromise = pipeline.exec({ keepErrors: true });
424
535
  this.pipelineCounter += 1;
425
536
  this.pipelinePromises.set(pipeline, pipelinePromise);
426
- this.activePipeline = null;
537
+ if (this.activeReadPipeline === pipeline) {
538
+ this.activeReadPipeline = null;
539
+ }
540
+ if (this.activeWritePipeline === pipeline) {
541
+ this.activeWritePipeline = null;
542
+ }
427
543
  }
428
544
  return this.pipelinePromises.get(pipeline);
429
545
  });
@@ -5326,7 +5442,7 @@ var Redis = class {
5326
5442
  };
5327
5443
 
5328
5444
  // version.ts
5329
- var VERSION = "v1.30.2";
5445
+ var VERSION = "v1.38.0";
5330
5446
 
5331
5447
  // platforms/cloudflare.ts
5332
5448
  var Redis2 = class _Redis extends Redis {
package/cloudflare.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-IH7W44G6.mjs";
6
+ } from "./chunk-2X4SLXT7.mjs";
7
7
 
8
8
  // platforms/cloudflare.ts
9
9
  var Redis2 = class _Redis extends Redis {
package/fastly.js CHANGED
@@ -341,6 +341,102 @@ function merge(obj, key, value) {
341
341
  }
342
342
 
343
343
  // pkg/auto-pipeline.ts
344
+ var MAX_PIPELINE_SIZE = 1e3;
345
+ var READ_COMMANDS = /* @__PURE__ */ new Set([
346
+ // String
347
+ "get",
348
+ "getrange",
349
+ "mget",
350
+ "strlen",
351
+ // Bit
352
+ "bitcount",
353
+ "bitpos",
354
+ "getbit",
355
+ // Hash
356
+ "hexists",
357
+ "hget",
358
+ "hgetall",
359
+ "hkeys",
360
+ "hlen",
361
+ "hmget",
362
+ "hrandfield",
363
+ "hscan",
364
+ "hstrlen",
365
+ "httl",
366
+ "hvals",
367
+ "hexpiretime",
368
+ "hpexpiretime",
369
+ "hpttl",
370
+ // List
371
+ "lindex",
372
+ "llen",
373
+ "lpos",
374
+ "lrange",
375
+ // Set
376
+ "scard",
377
+ "sdiff",
378
+ "sinter",
379
+ "sintercard",
380
+ "sismember",
381
+ "smembers",
382
+ "smismember",
383
+ "srandmember",
384
+ "sscan",
385
+ "sunion",
386
+ // Sorted set
387
+ "zcard",
388
+ "zcount",
389
+ "zlexcount",
390
+ "zmscore",
391
+ "zrange",
392
+ "zrank",
393
+ "zrevrank",
394
+ "zscan",
395
+ "zscore",
396
+ "zunion",
397
+ // Key metadata
398
+ "exists",
399
+ "type",
400
+ "ttl",
401
+ "pttl",
402
+ "randomkey",
403
+ "touch",
404
+ // HyperLogLog
405
+ "pfcount",
406
+ // Stream
407
+ "xinfo",
408
+ "xlen",
409
+ "xpending",
410
+ "xrange",
411
+ "xread",
412
+ "xrevrange",
413
+ // Geo
414
+ "geodist",
415
+ "geohash",
416
+ "geopos",
417
+ "geosearch",
418
+ // Script / eval
419
+ "scriptExists",
420
+ "evalRo",
421
+ "evalshaRo",
422
+ // Utility
423
+ "dbsize",
424
+ "echo",
425
+ "ping",
426
+ "time",
427
+ "scan",
428
+ "keys",
429
+ // JSON namespace
430
+ "arrindex",
431
+ "arrlen",
432
+ "objkeys",
433
+ "objlen",
434
+ "resp",
435
+ // Functions namespace
436
+ "list",
437
+ "stats",
438
+ "callRo"
439
+ ]);
344
440
  var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
345
441
  "scan",
346
442
  "keys",
@@ -387,7 +483,8 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
387
483
  const isFunction = typeof targetFunction === "function";
388
484
  if (isFunction) {
389
485
  return (...args) => {
390
- return redis2.autoPipelineExecutor.withAutoPipeline((pipeline2) => {
486
+ const commandMode = READ_COMMANDS.has(command) ? "read" : "write";
487
+ return redis2.autoPipelineExecutor.withAutoPipeline(commandMode, (pipeline2) => {
391
488
  const targetFunction2 = namespace === "json" ? pipeline2.json[command] : namespace === "functions" ? pipeline2.functions[command] : pipeline2[command];
392
489
  targetFunction2(...args);
393
490
  });
@@ -399,8 +496,10 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
399
496
  }
400
497
  var AutoPipelineExecutor = class {
401
498
  pipelinePromises = /* @__PURE__ */ new WeakMap();
402
- activePipeline = null;
403
- indexInCurrentPipeline = 0;
499
+ activeReadPipeline = null;
500
+ activeWritePipeline = null;
501
+ readIndex = 0;
502
+ writeIndex = 0;
404
503
  redis;
405
504
  pipeline;
406
505
  // only to make sure that proxy can work
@@ -410,20 +509,37 @@ var AutoPipelineExecutor = class {
410
509
  this.redis = redis;
411
510
  this.pipeline = redis.pipeline();
412
511
  }
413
- async withAutoPipeline(executeWithPipeline) {
414
- const pipeline = this.activePipeline ?? this.redis.pipeline();
415
- if (!this.activePipeline) {
416
- this.activePipeline = pipeline;
417
- this.indexInCurrentPipeline = 0;
512
+ async withAutoPipeline(commandMode, executeWithPipeline) {
513
+ const isRead = commandMode === "read";
514
+ const activePipeline = isRead ? this.activeReadPipeline : this.activeWritePipeline;
515
+ const pipeline = activePipeline ?? this.redis.pipeline();
516
+ if (!activePipeline) {
517
+ if (isRead) {
518
+ this.activeReadPipeline = pipeline;
519
+ this.readIndex = 0;
520
+ } else {
521
+ this.activeWritePipeline = pipeline;
522
+ this.writeIndex = 0;
523
+ }
418
524
  }
419
- const index = this.indexInCurrentPipeline++;
525
+ const index = isRead ? this.readIndex++ : this.writeIndex++;
420
526
  executeWithPipeline(pipeline);
527
+ if (isRead && this.readIndex >= MAX_PIPELINE_SIZE) {
528
+ this.activeReadPipeline = null;
529
+ } else if (!isRead && this.writeIndex >= MAX_PIPELINE_SIZE) {
530
+ this.activeWritePipeline = null;
531
+ }
421
532
  const pipelineDone = this.deferExecution().then(() => {
422
533
  if (!this.pipelinePromises.has(pipeline)) {
423
534
  const pipelinePromise = pipeline.exec({ keepErrors: true });
424
535
  this.pipelineCounter += 1;
425
536
  this.pipelinePromises.set(pipeline, pipelinePromise);
426
- this.activePipeline = null;
537
+ if (this.activeReadPipeline === pipeline) {
538
+ this.activeReadPipeline = null;
539
+ }
540
+ if (this.activeWritePipeline === pipeline) {
541
+ this.activeWritePipeline = null;
542
+ }
427
543
  }
428
544
  return this.pipelinePromises.get(pipeline);
429
545
  });
@@ -5326,7 +5442,7 @@ var Redis = class {
5326
5442
  };
5327
5443
 
5328
5444
  // version.ts
5329
- var VERSION = "v1.30.2";
5445
+ var VERSION = "v1.38.0";
5330
5446
 
5331
5447
  // platforms/fastly.ts
5332
5448
  var Redis2 = class extends Redis {
package/fastly.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-IH7W44G6.mjs";
6
+ } from "./chunk-2X4SLXT7.mjs";
7
7
 
8
8
  // platforms/fastly.ts
9
9
  var Redis2 = class extends Redis {
package/nodejs.js CHANGED
@@ -343,6 +343,102 @@ function merge(obj, key, value) {
343
343
  }
344
344
 
345
345
  // pkg/auto-pipeline.ts
346
+ var MAX_PIPELINE_SIZE = 1e3;
347
+ var READ_COMMANDS = /* @__PURE__ */ new Set([
348
+ // String
349
+ "get",
350
+ "getrange",
351
+ "mget",
352
+ "strlen",
353
+ // Bit
354
+ "bitcount",
355
+ "bitpos",
356
+ "getbit",
357
+ // Hash
358
+ "hexists",
359
+ "hget",
360
+ "hgetall",
361
+ "hkeys",
362
+ "hlen",
363
+ "hmget",
364
+ "hrandfield",
365
+ "hscan",
366
+ "hstrlen",
367
+ "httl",
368
+ "hvals",
369
+ "hexpiretime",
370
+ "hpexpiretime",
371
+ "hpttl",
372
+ // List
373
+ "lindex",
374
+ "llen",
375
+ "lpos",
376
+ "lrange",
377
+ // Set
378
+ "scard",
379
+ "sdiff",
380
+ "sinter",
381
+ "sintercard",
382
+ "sismember",
383
+ "smembers",
384
+ "smismember",
385
+ "srandmember",
386
+ "sscan",
387
+ "sunion",
388
+ // Sorted set
389
+ "zcard",
390
+ "zcount",
391
+ "zlexcount",
392
+ "zmscore",
393
+ "zrange",
394
+ "zrank",
395
+ "zrevrank",
396
+ "zscan",
397
+ "zscore",
398
+ "zunion",
399
+ // Key metadata
400
+ "exists",
401
+ "type",
402
+ "ttl",
403
+ "pttl",
404
+ "randomkey",
405
+ "touch",
406
+ // HyperLogLog
407
+ "pfcount",
408
+ // Stream
409
+ "xinfo",
410
+ "xlen",
411
+ "xpending",
412
+ "xrange",
413
+ "xread",
414
+ "xrevrange",
415
+ // Geo
416
+ "geodist",
417
+ "geohash",
418
+ "geopos",
419
+ "geosearch",
420
+ // Script / eval
421
+ "scriptExists",
422
+ "evalRo",
423
+ "evalshaRo",
424
+ // Utility
425
+ "dbsize",
426
+ "echo",
427
+ "ping",
428
+ "time",
429
+ "scan",
430
+ "keys",
431
+ // JSON namespace
432
+ "arrindex",
433
+ "arrlen",
434
+ "objkeys",
435
+ "objlen",
436
+ "resp",
437
+ // Functions namespace
438
+ "list",
439
+ "stats",
440
+ "callRo"
441
+ ]);
346
442
  var EXCLUDE_COMMANDS = /* @__PURE__ */ new Set([
347
443
  "scan",
348
444
  "keys",
@@ -389,7 +485,8 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
389
485
  const isFunction = typeof targetFunction === "function";
390
486
  if (isFunction) {
391
487
  return (...args) => {
392
- return redis2.autoPipelineExecutor.withAutoPipeline((pipeline2) => {
488
+ const commandMode = READ_COMMANDS.has(command) ? "read" : "write";
489
+ return redis2.autoPipelineExecutor.withAutoPipeline(commandMode, (pipeline2) => {
393
490
  const targetFunction2 = namespace === "json" ? pipeline2.json[command] : namespace === "functions" ? pipeline2.functions[command] : pipeline2[command];
394
491
  targetFunction2(...args);
395
492
  });
@@ -401,8 +498,10 @@ function createAutoPipelineProxy(_redis, namespace = "root") {
401
498
  }
402
499
  var AutoPipelineExecutor = class {
403
500
  pipelinePromises = /* @__PURE__ */ new WeakMap();
404
- activePipeline = null;
405
- indexInCurrentPipeline = 0;
501
+ activeReadPipeline = null;
502
+ activeWritePipeline = null;
503
+ readIndex = 0;
504
+ writeIndex = 0;
406
505
  redis;
407
506
  pipeline;
408
507
  // only to make sure that proxy can work
@@ -412,20 +511,37 @@ var AutoPipelineExecutor = class {
412
511
  this.redis = redis;
413
512
  this.pipeline = redis.pipeline();
414
513
  }
415
- async withAutoPipeline(executeWithPipeline) {
416
- const pipeline = this.activePipeline ?? this.redis.pipeline();
417
- if (!this.activePipeline) {
418
- this.activePipeline = pipeline;
419
- this.indexInCurrentPipeline = 0;
514
+ async withAutoPipeline(commandMode, executeWithPipeline) {
515
+ const isRead = commandMode === "read";
516
+ const activePipeline = isRead ? this.activeReadPipeline : this.activeWritePipeline;
517
+ const pipeline = activePipeline ?? this.redis.pipeline();
518
+ if (!activePipeline) {
519
+ if (isRead) {
520
+ this.activeReadPipeline = pipeline;
521
+ this.readIndex = 0;
522
+ } else {
523
+ this.activeWritePipeline = pipeline;
524
+ this.writeIndex = 0;
525
+ }
420
526
  }
421
- const index = this.indexInCurrentPipeline++;
527
+ const index = isRead ? this.readIndex++ : this.writeIndex++;
422
528
  executeWithPipeline(pipeline);
529
+ if (isRead && this.readIndex >= MAX_PIPELINE_SIZE) {
530
+ this.activeReadPipeline = null;
531
+ } else if (!isRead && this.writeIndex >= MAX_PIPELINE_SIZE) {
532
+ this.activeWritePipeline = null;
533
+ }
423
534
  const pipelineDone = this.deferExecution().then(() => {
424
535
  if (!this.pipelinePromises.has(pipeline)) {
425
536
  const pipelinePromise = pipeline.exec({ keepErrors: true });
426
537
  this.pipelineCounter += 1;
427
538
  this.pipelinePromises.set(pipeline, pipelinePromise);
428
- this.activePipeline = null;
539
+ if (this.activeReadPipeline === pipeline) {
540
+ this.activeReadPipeline = null;
541
+ }
542
+ if (this.activeWritePipeline === pipeline) {
543
+ this.activeWritePipeline = null;
544
+ }
429
545
  }
430
546
  return this.pipelinePromises.get(pipeline);
431
547
  });
@@ -5328,7 +5444,7 @@ var Redis = class {
5328
5444
  };
5329
5445
 
5330
5446
  // version.ts
5331
- var VERSION = "v1.30.2";
5447
+ var VERSION = "v1.38.0";
5332
5448
 
5333
5449
  // pkg/commands/search/schema-builder.ts
5334
5450
  var BUILD = /* @__PURE__ */ Symbol("build");
package/nodejs.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  SearchIndex,
5
5
  VERSION,
6
6
  error_exports
7
- } from "./chunk-IH7W44G6.mjs";
7
+ } from "./chunk-2X4SLXT7.mjs";
8
8
 
9
9
  // pkg/commands/search/schema-builder.ts
10
10
  var BUILD = /* @__PURE__ */ Symbol("build");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upstash/redis",
3
- "version": "1.37.0",
3
+ "version": "1.38.0",
4
4
  "main": "./nodejs.js",
5
5
  "module": "./nodejs.mjs",
6
6
  "types": "./nodejs.d.ts",