@upstash/redis 1.40.0 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/{chunk-RLVWMRRX.mjs → chunk-CGMWROAN.mjs} +557 -4
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +557 -4
- package/cloudflare.mjs +1 -1
- package/docs/advanced.mdx +83 -0
- package/docs/commands/array/arcount.mdx +28 -0
- package/docs/commands/array/ardel.mdx +30 -0
- package/docs/commands/array/ardelrange.mdx +32 -0
- package/docs/commands/array/arget.mdx +33 -0
- package/docs/commands/array/argetrange.mdx +38 -0
- package/docs/commands/array/argrep.mdx +69 -0
- package/docs/commands/array/arinfo.mdx +49 -0
- package/docs/commands/array/arinsert.mdx +32 -0
- package/docs/commands/array/arlastitems.mdx +40 -0
- package/docs/commands/array/arlen.mdx +28 -0
- package/docs/commands/array/armget.mdx +31 -0
- package/docs/commands/array/armset.mdx +31 -0
- package/docs/commands/array/arnext.mdx +25 -0
- package/docs/commands/array/arop.mdx +44 -0
- package/docs/commands/array/arring.mdx +36 -0
- package/docs/commands/array/arscan.mdx +42 -0
- package/docs/commands/array/arseek.mdx +34 -0
- package/docs/commands/array/arset.mdx +35 -0
- package/docs/commands/auth/echo.mdx +24 -0
- package/docs/commands/auth/ping.mdx +21 -0
- package/docs/commands/bitmap/bitcount.mdx +39 -0
- package/docs/commands/bitmap/bitop.mdx +142 -0
- package/docs/commands/bitmap/bitpos.mdx +39 -0
- package/docs/commands/bitmap/getbit.mdx +28 -0
- package/docs/commands/bitmap/setbit.mdx +31 -0
- package/docs/commands/connection/client_setinfo.mdx +91 -0
- package/docs/commands/functions/call.mdx +72 -0
- package/docs/commands/functions/call_ro.mdx +57 -0
- package/docs/commands/functions/delete.mdx +22 -0
- package/docs/commands/functions/flush.mdx +16 -0
- package/docs/commands/functions/list.mdx +72 -0
- package/docs/commands/functions/load.mdx +64 -0
- package/docs/commands/functions/stats.mdx +46 -0
- package/docs/commands/generic/del.mdx +29 -0
- package/docs/commands/generic/exists.mdx +26 -0
- package/docs/commands/generic/expire.mdx +29 -0
- package/docs/commands/generic/expireat.mdx +29 -0
- package/docs/commands/generic/keys.mdx +32 -0
- package/docs/commands/generic/persist.mdx +23 -0
- package/docs/commands/generic/pexpire.mdx +28 -0
- package/docs/commands/generic/pexpireat.mdx +29 -0
- package/docs/commands/generic/pttl.mdx +23 -0
- package/docs/commands/generic/randomkey.mdx +21 -0
- package/docs/commands/generic/rename.mdx +28 -0
- package/docs/commands/generic/renamenx.mdx +28 -0
- package/docs/commands/generic/scan.mdx +38 -0
- package/docs/commands/generic/touch.mdx +23 -0
- package/docs/commands/generic/ttl.mdx +23 -0
- package/docs/commands/generic/type.mdx +27 -0
- package/docs/commands/generic/unlink.mdx +29 -0
- package/docs/commands/hash/hdel.mdx +28 -0
- package/docs/commands/hash/hexists.mdx +30 -0
- package/docs/commands/hash/hexpire.mdx +49 -0
- package/docs/commands/hash/hexpireat.mdx +48 -0
- package/docs/commands/hash/hexpiretime.mdx +35 -0
- package/docs/commands/hash/hget.mdx +29 -0
- package/docs/commands/hash/hgetall.mdx +27 -0
- package/docs/commands/hash/hgetdel.mdx +67 -0
- package/docs/commands/hash/hgetex.mdx +123 -0
- package/docs/commands/hash/hincrby.mdx +34 -0
- package/docs/commands/hash/hincrbyfloat.mdx +34 -0
- package/docs/commands/hash/hkeys.mdx +28 -0
- package/docs/commands/hash/hlen.mdx +28 -0
- package/docs/commands/hash/hmget.mdx +33 -0
- package/docs/commands/hash/hpersist.mdx +37 -0
- package/docs/commands/hash/hpexpire.mdx +50 -0
- package/docs/commands/hash/hpexpireat.mdx +48 -0
- package/docs/commands/hash/hpexpiretime.mdx +35 -0
- package/docs/commands/hash/hpttl.mdx +35 -0
- package/docs/commands/hash/hrandfield.mdx +57 -0
- package/docs/commands/hash/hscan.mdx +65 -0
- package/docs/commands/hash/hset.mdx +32 -0
- package/docs/commands/hash/hsetex.mdx +186 -0
- package/docs/commands/hash/hsetnx.mdx +30 -0
- package/docs/commands/hash/hstrlen.mdx +28 -0
- package/docs/commands/hash/httl.mdx +35 -0
- package/docs/commands/hash/hvals.mdx +29 -0
- package/docs/commands/json/arrappend.mdx +35 -0
- package/docs/commands/json/arrindex.mdx +37 -0
- package/docs/commands/json/arrinsert.mdx +34 -0
- package/docs/commands/json/arrlen.mdx +26 -0
- package/docs/commands/json/arrpop.mdx +36 -0
- package/docs/commands/json/arrtrim.mdx +34 -0
- package/docs/commands/json/clear.mdx +30 -0
- package/docs/commands/json/del.mdx +26 -0
- package/docs/commands/json/forget.mdx +26 -0
- package/docs/commands/json/get.mdx +53 -0
- package/docs/commands/json/merge.mdx +32 -0
- package/docs/commands/json/mget.mdx +27 -0
- package/docs/commands/json/mset.mdx +26 -0
- package/docs/commands/json/numincrby.mdx +33 -0
- package/docs/commands/json/nummultby.mdx +33 -0
- package/docs/commands/json/objkeys.mdx +27 -0
- package/docs/commands/json/objlen.mdx +27 -0
- package/docs/commands/json/set.mdx +42 -0
- package/docs/commands/json/strappend.mdx +32 -0
- package/docs/commands/json/strlen.mdx +26 -0
- package/docs/commands/json/toggle.mdx +28 -0
- package/docs/commands/json/type.mdx +28 -0
- package/docs/commands/list/lindex.mdx +32 -0
- package/docs/commands/list/linsert.mdx +41 -0
- package/docs/commands/list/llen.mdx +26 -0
- package/docs/commands/list/lmove.mdx +34 -0
- package/docs/commands/list/lpop.mdx +37 -0
- package/docs/commands/list/lpos.mdx +56 -0
- package/docs/commands/list/lpush.mdx +32 -0
- package/docs/commands/list/lpushx.mdx +38 -0
- package/docs/commands/list/lrange.mdx +37 -0
- package/docs/commands/list/lrem.mdx +33 -0
- package/docs/commands/list/lset.mdx +34 -0
- package/docs/commands/list/ltrim.mdx +33 -0
- package/docs/commands/list/rpop.mdx +37 -0
- package/docs/commands/list/rpush.mdx +32 -0
- package/docs/commands/list/rpushx.mdx +38 -0
- package/docs/commands/overview.mdx +692 -0
- package/docs/commands/pubsub/psubscribe.mdx +36 -0
- package/docs/commands/pubsub/publish.mdx +27 -0
- package/docs/commands/pubsub/subscribe.mdx +28 -0
- package/docs/commands/scripts/eval.mdx +36 -0
- package/docs/commands/scripts/eval_ro.mdx +36 -0
- package/docs/commands/scripts/evalsha.mdx +36 -0
- package/docs/commands/scripts/evalsha_ro.mdx +36 -0
- package/docs/commands/scripts/script_exists.mdx +26 -0
- package/docs/commands/scripts/script_flush.mdx +28 -0
- package/docs/commands/scripts/script_load.mdx +28 -0
- package/docs/commands/server/dbsize.mdx +22 -0
- package/docs/commands/server/flushall.mdx +25 -0
- package/docs/commands/server/flushdb.mdx +25 -0
- package/docs/commands/set/sadd.mdx +32 -0
- package/docs/commands/set/scard.mdx +26 -0
- package/docs/commands/set/sdiff.mdx +27 -0
- package/docs/commands/set/sdiffstore.mdx +32 -0
- package/docs/commands/set/sinter.mdx +27 -0
- package/docs/commands/set/sinterstore.mdx +33 -0
- package/docs/commands/set/sismember.mdx +30 -0
- package/docs/commands/set/smembers.mdx +25 -0
- package/docs/commands/set/smismember.mdx +31 -0
- package/docs/commands/set/smove.mdx +34 -0
- package/docs/commands/set/spop.mdx +36 -0
- package/docs/commands/set/srandmember.mdx +36 -0
- package/docs/commands/set/srem.mdx +29 -0
- package/docs/commands/set/sscan.mdx +39 -0
- package/docs/commands/set/sunion.mdx +27 -0
- package/docs/commands/set/sunionstore.mdx +33 -0
- package/docs/commands/stream/xack.mdx +37 -0
- package/docs/commands/stream/xackdel.mdx +211 -0
- package/docs/commands/stream/xadd.mdx +137 -0
- package/docs/commands/stream/xautoclaim.mdx +80 -0
- package/docs/commands/stream/xclaim.mdx +84 -0
- package/docs/commands/stream/xdel.mdx +34 -0
- package/docs/commands/stream/xdelex.mdx +119 -0
- package/docs/commands/stream/xgroup.mdx +141 -0
- package/docs/commands/stream/xinfo.mdx +77 -0
- package/docs/commands/stream/xlen.mdx +22 -0
- package/docs/commands/stream/xpending.mdx +75 -0
- package/docs/commands/stream/xrange.mdx +59 -0
- package/docs/commands/stream/xread.mdx +65 -0
- package/docs/commands/stream/xreadgroup.mdx +87 -0
- package/docs/commands/stream/xrevrange.mdx +65 -0
- package/docs/commands/stream/xtrim.mdx +75 -0
- package/docs/commands/string/append.mdx +28 -0
- package/docs/commands/string/decr.mdx +27 -0
- package/docs/commands/string/decrby.mdx +30 -0
- package/docs/commands/string/get.mdx +34 -0
- package/docs/commands/string/getdel.mdx +29 -0
- package/docs/commands/string/getrange.mdx +34 -0
- package/docs/commands/string/getset.mdx +28 -0
- package/docs/commands/string/incr.mdx +27 -0
- package/docs/commands/string/incrby.mdx +30 -0
- package/docs/commands/string/incrbyfloat.mdx +30 -0
- package/docs/commands/string/mget.mdx +31 -0
- package/docs/commands/string/mset.mdx +32 -0
- package/docs/commands/string/msetnx.mdx +29 -0
- package/docs/commands/string/set.mdx +79 -0
- package/docs/commands/string/setrange.mdx +38 -0
- package/docs/commands/string/strlen.mdx +26 -0
- package/docs/commands/transaction.mdx +22 -0
- package/docs/commands/zset/zadd.mdx +102 -0
- package/docs/commands/zset/zcard.mdx +31 -0
- package/docs/commands/zset/zcount.mdx +47 -0
- package/docs/commands/zset/zdiffstore.mdx +33 -0
- package/docs/commands/zset/zincrby.mdx +37 -0
- package/docs/commands/zset/zinterstore.mdx +98 -0
- package/docs/commands/zset/zlexcount.mdx +43 -0
- package/docs/commands/zset/zmscore.mdx +34 -0
- package/docs/commands/zset/zpopmax.mdx +25 -0
- package/docs/commands/zset/zpopmin.mdx +25 -0
- package/docs/commands/zset/zrange.mdx +85 -0
- package/docs/commands/zset/zrank.mdx +29 -0
- package/docs/commands/zset/zrem.mdx +33 -0
- package/docs/commands/zset/zremrangebylex.mdx +32 -0
- package/docs/commands/zset/zremrangebyrank.mdx +32 -0
- package/docs/commands/zset/zremrangebyscore.mdx +32 -0
- package/docs/commands/zset/zrevrank.mdx +29 -0
- package/docs/commands/zset/zscan.mdx +58 -0
- package/docs/commands/zset/zscore.mdx +34 -0
- package/docs/commands/zset/zunionstore.mdx +98 -0
- package/docs/deployment.mdx +117 -0
- package/docs/developing.mdx +118 -0
- package/docs/getstarted.mdx +68 -0
- package/docs/overview.mdx +29 -0
- package/docs/pipelining/auto-pipeline.mdx +108 -0
- package/docs/pipelining/pipeline-transaction.mdx +65 -0
- package/docs/retries.mdx +24 -0
- package/docs/troubleshooting.mdx +80 -0
- package/{error-BNzLTXJG.d.mts → error-4e36-PC0.d.mts} +838 -8
- package/{error-BNzLTXJG.d.ts → error-4e36-PC0.d.ts} +838 -8
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +557 -4
- package/fastly.mjs +1 -1
- package/nodejs.d.mts +34 -2
- package/nodejs.d.ts +34 -2
- package/nodejs.js +586 -4
- package/nodejs.mjs +30 -1
- package/package.json +16 -5
- package/src/pkg/auto-pipeline.ts +284 -0
- package/src/pkg/commands/append.ts +12 -0
- package/src/pkg/commands/arcount.ts +14 -0
- package/src/pkg/commands/ardel.ts +19 -0
- package/src/pkg/commands/ardelrange.ts +19 -0
- package/src/pkg/commands/arget.ts +17 -0
- package/src/pkg/commands/argetrange.ts +20 -0
- package/src/pkg/commands/argrep.ts +109 -0
- package/src/pkg/commands/arinfo.ts +88 -0
- package/src/pkg/commands/arinsert.ts +24 -0
- package/src/pkg/commands/arlastitems.ts +29 -0
- package/src/pkg/commands/arlen.ts +23 -0
- package/src/pkg/commands/armget.ts +18 -0
- package/src/pkg/commands/armset.ts +26 -0
- package/src/pkg/commands/arnext.ts +20 -0
- package/src/pkg/commands/arop.ts +48 -0
- package/src/pkg/commands/arring.ts +23 -0
- package/src/pkg/commands/arscan.ts +44 -0
- package/src/pkg/commands/arseek.ts +17 -0
- package/src/pkg/commands/arset.ts +20 -0
- package/src/pkg/commands/bitcount.ts +30 -0
- package/src/pkg/commands/bitfield.ts +50 -0
- package/src/pkg/commands/bitop.ts +35 -0
- package/src/pkg/commands/bitpos.ts +15 -0
- package/src/pkg/commands/client_setinfo.ts +17 -0
- package/src/pkg/commands/command.ts +142 -0
- package/src/pkg/commands/copy.ts +22 -0
- package/src/pkg/commands/dbsize.ts +12 -0
- package/src/pkg/commands/decr.ts +12 -0
- package/src/pkg/commands/decrby.ts +12 -0
- package/src/pkg/commands/del.ts +12 -0
- package/src/pkg/commands/echo.ts +12 -0
- package/src/pkg/commands/eval.ts +18 -0
- package/src/pkg/commands/evalRo.ts +18 -0
- package/src/pkg/commands/evalsha.ts +18 -0
- package/src/pkg/commands/evalshaRo.ts +18 -0
- package/src/pkg/commands/exec.ts +23 -0
- package/src/pkg/commands/exists.ts +12 -0
- package/src/pkg/commands/expire.ts +13 -0
- package/src/pkg/commands/expireat.ts +16 -0
- package/src/pkg/commands/fcall.ts +15 -0
- package/src/pkg/commands/fcall_ro.ts +18 -0
- package/src/pkg/commands/flushall.ts +15 -0
- package/src/pkg/commands/flushdb.ts +15 -0
- package/src/pkg/commands/function_delete.ts +12 -0
- package/src/pkg/commands/function_flush.ts +12 -0
- package/src/pkg/commands/function_list.ts +77 -0
- package/src/pkg/commands/function_load.ts +31 -0
- package/src/pkg/commands/function_stats.ts +42 -0
- package/src/pkg/commands/geo_add.ts +54 -0
- package/src/pkg/commands/geo_dist.ts +19 -0
- package/src/pkg/commands/geo_hash.ts +23 -0
- package/src/pkg/commands/geo_pos.ts +39 -0
- package/src/pkg/commands/geo_search.ts +140 -0
- package/src/pkg/commands/geo_search_store.ts +69 -0
- package/src/pkg/commands/get.ts +15 -0
- package/src/pkg/commands/getbit.ts +12 -0
- package/src/pkg/commands/getdel.ts +15 -0
- package/src/pkg/commands/getex.ts +36 -0
- package/src/pkg/commands/getrange.ts +15 -0
- package/src/pkg/commands/getset.ts +15 -0
- package/src/pkg/commands/hdel.ts +12 -0
- package/src/pkg/commands/hexists.ts +12 -0
- package/src/pkg/commands/hexpire.ts +30 -0
- package/src/pkg/commands/hexpireat.ts +30 -0
- package/src/pkg/commands/hexpiretime.ts +13 -0
- package/src/pkg/commands/hget.ts +18 -0
- package/src/pkg/commands/hgetall.ts +44 -0
- package/src/pkg/commands/hgetdel.ts +30 -0
- package/src/pkg/commands/hgetex.ts +56 -0
- package/src/pkg/commands/hincrby.ts +15 -0
- package/src/pkg/commands/hincrbyfloat.ts +15 -0
- package/src/pkg/commands/hkeys.ts +12 -0
- package/src/pkg/commands/hlen.ts +12 -0
- package/src/pkg/commands/hmget.ts +53 -0
- package/src/pkg/commands/hmset.ts +14 -0
- package/src/pkg/commands/hpersist.ts +13 -0
- package/src/pkg/commands/hpexpire.ts +30 -0
- package/src/pkg/commands/hpexpireat.ts +30 -0
- package/src/pkg/commands/hpexpiretime.ts +13 -0
- package/src/pkg/commands/hpttl.ts +13 -0
- package/src/pkg/commands/hrandfield.ts +52 -0
- package/src/pkg/commands/hscan.ts +31 -0
- package/src/pkg/commands/hset.ts +15 -0
- package/src/pkg/commands/hsetex.ts +59 -0
- package/src/pkg/commands/hsetnx.ts +15 -0
- package/src/pkg/commands/hstrlen.ts +12 -0
- package/src/pkg/commands/httl.ts +13 -0
- package/src/pkg/commands/hvals.ts +12 -0
- package/src/pkg/commands/incr.ts +12 -0
- package/src/pkg/commands/incrby.ts +12 -0
- package/src/pkg/commands/incrbyfloat.ts +12 -0
- package/src/pkg/commands/json_arrappend.ts +18 -0
- package/src/pkg/commands/json_arrindex.ts +15 -0
- package/src/pkg/commands/json_arrinsert.ts +18 -0
- package/src/pkg/commands/json_arrlen.ts +15 -0
- package/src/pkg/commands/json_arrpop.ts +15 -0
- package/src/pkg/commands/json_arrtrim.ts +19 -0
- package/src/pkg/commands/json_clear.ts +12 -0
- package/src/pkg/commands/json_del.ts +12 -0
- package/src/pkg/commands/json_forget.ts +12 -0
- package/src/pkg/commands/json_get.ts +45 -0
- package/src/pkg/commands/json_merge.ts +18 -0
- package/src/pkg/commands/json_mget.ts +12 -0
- package/src/pkg/commands/json_mset.ts +27 -0
- package/src/pkg/commands/json_numincrby.ts +15 -0
- package/src/pkg/commands/json_nummultby.ts +15 -0
- package/src/pkg/commands/json_objkeys.ts +15 -0
- package/src/pkg/commands/json_objlen.ts +15 -0
- package/src/pkg/commands/json_resp.ts +11 -0
- package/src/pkg/commands/json_set.ts +35 -0
- package/src/pkg/commands/json_strappend.ts +15 -0
- package/src/pkg/commands/json_strlen.ts +15 -0
- package/src/pkg/commands/json_toggle.ts +12 -0
- package/src/pkg/commands/json_type.ts +12 -0
- package/src/pkg/commands/keys.ts +12 -0
- package/src/pkg/commands/lindex.ts +11 -0
- package/src/pkg/commands/linsert.ts +10 -0
- package/src/pkg/commands/llen.ts +12 -0
- package/src/pkg/commands/lmove.ts +20 -0
- package/src/pkg/commands/lmpop.ts +19 -0
- package/src/pkg/commands/lpop.ts +18 -0
- package/src/pkg/commands/lpos.ts +26 -0
- package/src/pkg/commands/lpush.ts +12 -0
- package/src/pkg/commands/lpushx.ts +12 -0
- package/src/pkg/commands/lrange.ts +11 -0
- package/src/pkg/commands/lrem.ts +10 -0
- package/src/pkg/commands/lset.ts +8 -0
- package/src/pkg/commands/ltrim.ts +8 -0
- package/src/pkg/commands/mget.ts +15 -0
- package/src/pkg/commands/mod.ts +222 -0
- package/src/pkg/commands/mset.ts +12 -0
- package/src/pkg/commands/msetnx.ts +12 -0
- package/src/pkg/commands/persist.ts +12 -0
- package/src/pkg/commands/pexpire.ts +16 -0
- package/src/pkg/commands/pexpireat.ts +16 -0
- package/src/pkg/commands/pfadd.ts +11 -0
- package/src/pkg/commands/pfcount.ts +11 -0
- package/src/pkg/commands/pfmerge.ts +11 -0
- package/src/pkg/commands/ping.ts +15 -0
- package/src/pkg/commands/psetex.ts +14 -0
- package/src/pkg/commands/psubscribe.ts +26 -0
- package/src/pkg/commands/pttl.ts +12 -0
- package/src/pkg/commands/publish.ts +12 -0
- package/src/pkg/commands/randomkey.ts +12 -0
- package/src/pkg/commands/rename.ts +12 -0
- package/src/pkg/commands/renamenx.ts +12 -0
- package/src/pkg/commands/rpop.ts +21 -0
- package/src/pkg/commands/rpush.ts +12 -0
- package/src/pkg/commands/rpushx.ts +12 -0
- package/src/pkg/commands/sadd.ts +15 -0
- package/src/pkg/commands/scan.ts +63 -0
- package/src/pkg/commands/scard.ts +11 -0
- package/src/pkg/commands/script_exists.ts +15 -0
- package/src/pkg/commands/script_flush.ts +22 -0
- package/src/pkg/commands/script_load.ts +12 -0
- package/src/pkg/commands/sdiff.ts +11 -0
- package/src/pkg/commands/sdiffstore.ts +14 -0
- package/src/pkg/commands/search/command-builder.ts +162 -0
- package/src/pkg/commands/search/index.ts +4 -0
- package/src/pkg/commands/search/schema-builder.ts +320 -0
- package/src/pkg/commands/search/search.ts +218 -0
- package/src/pkg/commands/search/types.ts +1029 -0
- package/src/pkg/commands/search/utils.ts +275 -0
- package/src/pkg/commands/set.ts +52 -0
- package/src/pkg/commands/setbit.ts +15 -0
- package/src/pkg/commands/setex.ts +11 -0
- package/src/pkg/commands/setnx.ts +11 -0
- package/src/pkg/commands/setrange.ts +15 -0
- package/src/pkg/commands/sinter.ts +11 -0
- package/src/pkg/commands/sintercard.ts +19 -0
- package/src/pkg/commands/sinterstore.ts +14 -0
- package/src/pkg/commands/sismember.ts +11 -0
- package/src/pkg/commands/smembers.ts +12 -0
- package/src/pkg/commands/smismember.ts +17 -0
- package/src/pkg/commands/smove.ts +14 -0
- package/src/pkg/commands/spop.ts +18 -0
- package/src/pkg/commands/srandmember.ts +18 -0
- package/src/pkg/commands/srem.ts +11 -0
- package/src/pkg/commands/sscan.ts +31 -0
- package/src/pkg/commands/strlen.ts +12 -0
- package/src/pkg/commands/subscribe.ts +254 -0
- package/src/pkg/commands/sunion.ts +12 -0
- package/src/pkg/commands/sunionstore.ts +15 -0
- package/src/pkg/commands/time.ts +10 -0
- package/src/pkg/commands/touch.ts +12 -0
- package/src/pkg/commands/ttl.ts +12 -0
- package/src/pkg/commands/type.ts +13 -0
- package/src/pkg/commands/types.ts +201 -0
- package/src/pkg/commands/unlink.ts +12 -0
- package/src/pkg/commands/vector/index.ts +11 -0
- package/src/pkg/commands/vector/types.ts +63 -0
- package/src/pkg/commands/vector/utils.ts +67 -0
- package/src/pkg/commands/vector/vector.ts +131 -0
- package/src/pkg/commands/vector_add.ts +18 -0
- package/src/pkg/commands/vector_count.ts +11 -0
- package/src/pkg/commands/vector_create.ts +28 -0
- package/src/pkg/commands/vector_del.ts +13 -0
- package/src/pkg/commands/vector_drop.ts +13 -0
- package/src/pkg/commands/vector_get.ts +18 -0
- package/src/pkg/commands/vector_info.ts +25 -0
- package/src/pkg/commands/vector_query.ts +24 -0
- package/src/pkg/commands/xack.ts +16 -0
- package/src/pkg/commands/xackdel.ts +21 -0
- package/src/pkg/commands/xadd.ts +70 -0
- package/src/pkg/commands/xautoclaim.ts +31 -0
- package/src/pkg/commands/xclaim.ts +56 -0
- package/src/pkg/commands/xdel.ts +16 -0
- package/src/pkg/commands/xdelex.ts +25 -0
- package/src/pkg/commands/xgroup.ts +101 -0
- package/src/pkg/commands/xinfo.ts +28 -0
- package/src/pkg/commands/xlen.ts +12 -0
- package/src/pkg/commands/xpending.ts +44 -0
- package/src/pkg/commands/xrange.ts +49 -0
- package/src/pkg/commands/xread.ts +78 -0
- package/src/pkg/commands/xreadgroup.ts +74 -0
- package/src/pkg/commands/xrevrange.ts +48 -0
- package/src/pkg/commands/xtrim.ts +25 -0
- package/src/pkg/commands/zadd.ts +54 -0
- package/src/pkg/commands/zcard.ts +12 -0
- package/src/pkg/commands/zcount.ts +14 -0
- package/src/pkg/commands/zdiffstore.ts +15 -0
- package/src/pkg/commands/zincrby.ts +14 -0
- package/src/pkg/commands/zinterstore.ts +51 -0
- package/src/pkg/commands/zlexcount.ts +11 -0
- package/src/pkg/commands/zmscore.ts +16 -0
- package/src/pkg/commands/zpopmax.ts +18 -0
- package/src/pkg/commands/zpopmin.ts +18 -0
- package/src/pkg/commands/zrange.ts +72 -0
- package/src/pkg/commands/zrank.ts +14 -0
- package/src/pkg/commands/zrem.ts +11 -0
- package/src/pkg/commands/zremrangebylex.ts +11 -0
- package/src/pkg/commands/zremrangebyrank.ts +14 -0
- package/src/pkg/commands/zremrangebyscore.ts +18 -0
- package/src/pkg/commands/zrevrank.ts +14 -0
- package/src/pkg/commands/zscan.ts +31 -0
- package/src/pkg/commands/zscore.ts +15 -0
- package/src/pkg/commands/zunion.ts +54 -0
- package/src/pkg/commands/zunionstore.ts +52 -0
- package/src/pkg/error.ts +28 -0
- package/src/pkg/http.ts +458 -0
- package/src/pkg/index.ts +1 -0
- package/src/pkg/pipeline.ts +2041 -0
- package/src/pkg/redis.ts +2130 -0
- package/src/pkg/script.ts +100 -0
- package/src/pkg/scriptRo.ts +98 -0
- package/src/pkg/types.ts +35 -0
- package/src/pkg/util.ts +115 -0
- package/src/platforms/cloudflare.ts +162 -0
- package/src/platforms/fastly.ts +105 -0
- package/src/platforms/nodejs.ts +231 -0
- package/src/version.ts +1 -0
package/nodejs.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
VERSION,
|
|
6
6
|
VectorIndex,
|
|
7
7
|
error_exports
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CGMWROAN.mjs";
|
|
9
9
|
|
|
10
10
|
// pkg/commands/search/schema-builder.ts
|
|
11
11
|
var BUILD = /* @__PURE__ */ Symbol("build");
|
|
@@ -133,6 +133,27 @@ var DateFieldBuilder = class _DateFieldBuilder {
|
|
|
133
133
|
return { type: "DATE" };
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
+
var HybridFieldBuilder = class _HybridFieldBuilder {
|
|
137
|
+
_noStem;
|
|
138
|
+
_from;
|
|
139
|
+
constructor(noStem = { noStem: false }, from = { from: null }) {
|
|
140
|
+
this._noStem = noStem;
|
|
141
|
+
this._from = from;
|
|
142
|
+
}
|
|
143
|
+
noStem() {
|
|
144
|
+
return new _HybridFieldBuilder({ noStem: true }, this._from);
|
|
145
|
+
}
|
|
146
|
+
from(field) {
|
|
147
|
+
return new _HybridFieldBuilder(this._noStem, { from: field });
|
|
148
|
+
}
|
|
149
|
+
[BUILD]() {
|
|
150
|
+
return {
|
|
151
|
+
type: "HYBRID",
|
|
152
|
+
...this._noStem.noStem ? { noStem: true } : {},
|
|
153
|
+
...this._from.from ? { from: this._from.from } : {}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
};
|
|
136
157
|
var KeywordFieldBuilder = class {
|
|
137
158
|
[BUILD]() {
|
|
138
159
|
return { type: "KEYWORD" };
|
|
@@ -156,6 +177,14 @@ var s = {
|
|
|
156
177
|
date() {
|
|
157
178
|
return new DateFieldBuilder();
|
|
158
179
|
},
|
|
180
|
+
/**
|
|
181
|
+
* A TEXT field that is also embedded for semantic search with `$ann`.
|
|
182
|
+
*
|
|
183
|
+
* @see https://upstash.com/docs/redis/search/hybrid-search
|
|
184
|
+
*/
|
|
185
|
+
hybrid() {
|
|
186
|
+
return new HybridFieldBuilder();
|
|
187
|
+
},
|
|
159
188
|
keyword() {
|
|
160
189
|
return new KeywordFieldBuilder();
|
|
161
190
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upstash/redis",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"main": "./nodejs.js",
|
|
5
5
|
"module": "./nodejs.mjs",
|
|
6
6
|
"types": "./nodejs.d.ts",
|
|
@@ -51,12 +51,22 @@
|
|
|
51
51
|
"upstash"
|
|
52
52
|
],
|
|
53
53
|
"files": [
|
|
54
|
-
"./*"
|
|
54
|
+
"./*",
|
|
55
|
+
"!src/**/*.test.*",
|
|
56
|
+
"!src/**/*.test-d.*",
|
|
57
|
+
"!src/**/*.spec.*",
|
|
58
|
+
"!src/**/test-utils.*",
|
|
59
|
+
"!src/**/__tests__/**",
|
|
60
|
+
"!src/**/__snapshots__/**"
|
|
55
61
|
],
|
|
62
|
+
"directories": {
|
|
63
|
+
"doc": "./docs"
|
|
64
|
+
},
|
|
56
65
|
"scripts": {
|
|
57
|
-
"build": "tsup && cp package.json README.md ../../LICENSE dist/",
|
|
58
|
-
"test": "bun test pkg --bail --timeout 20000",
|
|
59
|
-
"check-exports": "bun run build && cd dist && attw -P"
|
|
66
|
+
"build": "tsup && mkdir -p dist/src && cp -R pkg platforms version.ts dist/src/ && find dist/src \\( -name '*.test.ts' -o -name test-utils.ts \\) -delete && cp package.json README.md ../../LICENSE dist/",
|
|
67
|
+
"test": "bun test ./pkg --bail --timeout 20000",
|
|
68
|
+
"check-exports": "bun run build && cd dist && attw -P",
|
|
69
|
+
"prepack": "giget gh:upstash/docs/redis/sdks/ts docs --force-clean 1>&2"
|
|
60
70
|
},
|
|
61
71
|
"publishConfig": {
|
|
62
72
|
"access": "public"
|
|
@@ -69,6 +79,7 @@
|
|
|
69
79
|
"homepage": "https://github.com/upstash/upstash-redis#readme",
|
|
70
80
|
"devDependencies": {
|
|
71
81
|
"@types/bun": "1.3.6",
|
|
82
|
+
"giget": "3.3.1",
|
|
72
83
|
"tsup": "^8.2.3",
|
|
73
84
|
"typescript": "latest"
|
|
74
85
|
},
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import type { Command } from "./commands/command";
|
|
2
|
+
import { UpstashError } from "./error";
|
|
3
|
+
import type { UpstashResponse } from "./http";
|
|
4
|
+
import type { Pipeline } from "./pipeline";
|
|
5
|
+
import type { Redis } from "./redis";
|
|
6
|
+
import type { CommandArgs } from "./types";
|
|
7
|
+
|
|
8
|
+
// properties which are only available in redis
|
|
9
|
+
type redisOnly = Exclude<keyof Redis, keyof Pipeline>;
|
|
10
|
+
|
|
11
|
+
export const MAX_PIPELINE_SIZE = 1000;
|
|
12
|
+
|
|
13
|
+
const READ_COMMANDS: Set<string> = new Set([
|
|
14
|
+
// Array
|
|
15
|
+
"arcount",
|
|
16
|
+
"arget",
|
|
17
|
+
"argetrange",
|
|
18
|
+
"argrep",
|
|
19
|
+
"arinfo",
|
|
20
|
+
"arlastitems",
|
|
21
|
+
"arlen",
|
|
22
|
+
"armget",
|
|
23
|
+
"arnext",
|
|
24
|
+
"arop",
|
|
25
|
+
"arscan",
|
|
26
|
+
// String
|
|
27
|
+
"get",
|
|
28
|
+
"getrange",
|
|
29
|
+
"mget",
|
|
30
|
+
"strlen",
|
|
31
|
+
// Bit
|
|
32
|
+
"bitcount",
|
|
33
|
+
"bitpos",
|
|
34
|
+
"getbit",
|
|
35
|
+
// Hash
|
|
36
|
+
"hexists",
|
|
37
|
+
"hget",
|
|
38
|
+
"hgetall",
|
|
39
|
+
"hkeys",
|
|
40
|
+
"hlen",
|
|
41
|
+
"hmget",
|
|
42
|
+
"hrandfield",
|
|
43
|
+
"hscan",
|
|
44
|
+
"hstrlen",
|
|
45
|
+
"httl",
|
|
46
|
+
"hvals",
|
|
47
|
+
"hexpiretime",
|
|
48
|
+
"hpexpiretime",
|
|
49
|
+
"hpttl",
|
|
50
|
+
// List
|
|
51
|
+
"lindex",
|
|
52
|
+
"llen",
|
|
53
|
+
"lpos",
|
|
54
|
+
"lrange",
|
|
55
|
+
// Set
|
|
56
|
+
"scard",
|
|
57
|
+
"sdiff",
|
|
58
|
+
"sinter",
|
|
59
|
+
"sintercard",
|
|
60
|
+
"sismember",
|
|
61
|
+
"smembers",
|
|
62
|
+
"smismember",
|
|
63
|
+
"srandmember",
|
|
64
|
+
"sscan",
|
|
65
|
+
"sunion",
|
|
66
|
+
// Sorted set
|
|
67
|
+
"zcard",
|
|
68
|
+
"zcount",
|
|
69
|
+
"zlexcount",
|
|
70
|
+
"zmscore",
|
|
71
|
+
"zrange",
|
|
72
|
+
"zrank",
|
|
73
|
+
"zrevrank",
|
|
74
|
+
"zscan",
|
|
75
|
+
"zscore",
|
|
76
|
+
"zunion",
|
|
77
|
+
// Key metadata
|
|
78
|
+
"exists",
|
|
79
|
+
"type",
|
|
80
|
+
"ttl",
|
|
81
|
+
"pttl",
|
|
82
|
+
"randomkey",
|
|
83
|
+
"touch",
|
|
84
|
+
// HyperLogLog
|
|
85
|
+
"pfcount",
|
|
86
|
+
// Stream
|
|
87
|
+
"xinfo",
|
|
88
|
+
"xlen",
|
|
89
|
+
"xpending",
|
|
90
|
+
"xrange",
|
|
91
|
+
"xread",
|
|
92
|
+
"xrevrange",
|
|
93
|
+
// Geo
|
|
94
|
+
"geodist",
|
|
95
|
+
"geohash",
|
|
96
|
+
"geopos",
|
|
97
|
+
"geosearch",
|
|
98
|
+
// Script / eval
|
|
99
|
+
"scriptExists",
|
|
100
|
+
"evalRo",
|
|
101
|
+
"evalshaRo",
|
|
102
|
+
// Utility
|
|
103
|
+
"dbsize",
|
|
104
|
+
"echo",
|
|
105
|
+
"ping",
|
|
106
|
+
"time",
|
|
107
|
+
"scan",
|
|
108
|
+
"keys",
|
|
109
|
+
// JSON namespace
|
|
110
|
+
"arrindex",
|
|
111
|
+
"arrlen",
|
|
112
|
+
"objkeys",
|
|
113
|
+
"objlen",
|
|
114
|
+
"resp",
|
|
115
|
+
// Functions namespace
|
|
116
|
+
"list",
|
|
117
|
+
"stats",
|
|
118
|
+
"callRo",
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
export const EXCLUDE_COMMANDS: Set<keyof Redis> = new Set([
|
|
122
|
+
"scan",
|
|
123
|
+
"keys",
|
|
124
|
+
"flushdb",
|
|
125
|
+
"flushall",
|
|
126
|
+
"dbsize",
|
|
127
|
+
"hscan",
|
|
128
|
+
"hgetall",
|
|
129
|
+
"hkeys",
|
|
130
|
+
"lrange",
|
|
131
|
+
"sscan",
|
|
132
|
+
"smembers",
|
|
133
|
+
"xrange",
|
|
134
|
+
"xrevrange",
|
|
135
|
+
"zscan",
|
|
136
|
+
"zrange",
|
|
137
|
+
"exec",
|
|
138
|
+
]);
|
|
139
|
+
|
|
140
|
+
type AutoPipelineNamespace = "root" | "json" | "functions";
|
|
141
|
+
|
|
142
|
+
export function createAutoPipelineProxy(
|
|
143
|
+
_redis: Redis,
|
|
144
|
+
namespace: AutoPipelineNamespace = "root"
|
|
145
|
+
): Redis {
|
|
146
|
+
const redis = _redis as Redis & {
|
|
147
|
+
autoPipelineExecutor: AutoPipelineExecutor;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
if (!redis.autoPipelineExecutor) {
|
|
151
|
+
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return new Proxy(redis, {
|
|
155
|
+
get: (redis, command: "pipelineCounter" | keyof Pipeline | redisOnly) => {
|
|
156
|
+
// return pipelineCounter of autoPipelineExecutor
|
|
157
|
+
if (command === "pipelineCounter") {
|
|
158
|
+
return redis.autoPipelineExecutor.pipelineCounter;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Namespace switching
|
|
162
|
+
if (namespace === "root" && command === "json") {
|
|
163
|
+
return createAutoPipelineProxy(redis, "json");
|
|
164
|
+
}
|
|
165
|
+
if (namespace === "root" && command === "functions") {
|
|
166
|
+
return createAutoPipelineProxy(redis, "functions");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Root-level: some commands should bypass auto pipelining
|
|
170
|
+
if (namespace === "root") {
|
|
171
|
+
const commandInRedisButNotPipeline =
|
|
172
|
+
command in redis && !(command in redis.autoPipelineExecutor.pipeline);
|
|
173
|
+
const isCommandExcluded = EXCLUDE_COMMANDS.has(command as keyof Redis);
|
|
174
|
+
|
|
175
|
+
if (commandInRedisButNotPipeline || isCommandExcluded) {
|
|
176
|
+
return redis[command as redisOnly];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const pipeline = redis.autoPipelineExecutor.pipeline;
|
|
181
|
+
const targetFunction =
|
|
182
|
+
namespace === "json"
|
|
183
|
+
? pipeline.json[command as keyof typeof pipeline.json]
|
|
184
|
+
: namespace === "functions"
|
|
185
|
+
? pipeline.functions[command as keyof typeof pipeline.functions]
|
|
186
|
+
: pipeline[command as keyof Pipeline];
|
|
187
|
+
|
|
188
|
+
const isFunction = typeof targetFunction === "function";
|
|
189
|
+
if (isFunction) {
|
|
190
|
+
return (...args: CommandArgs<typeof Command>) => {
|
|
191
|
+
const commandMode = READ_COMMANDS.has(command as string) ? "read" : "write";
|
|
192
|
+
return redis.autoPipelineExecutor.withAutoPipeline(commandMode, (pipeline) => {
|
|
193
|
+
const targetFunction =
|
|
194
|
+
namespace === "json"
|
|
195
|
+
? pipeline.json[command as keyof typeof pipeline.json]
|
|
196
|
+
: namespace === "functions"
|
|
197
|
+
? pipeline.functions[command as keyof typeof pipeline.functions]
|
|
198
|
+
: pipeline[command as keyof Pipeline];
|
|
199
|
+
|
|
200
|
+
(targetFunction as any)(...args);
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return targetFunction;
|
|
206
|
+
},
|
|
207
|
+
}) as Redis;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
type CommandMode = "read" | "write";
|
|
211
|
+
|
|
212
|
+
class AutoPipelineExecutor {
|
|
213
|
+
private pipelinePromises = new WeakMap<Pipeline, Promise<unknown[]>>();
|
|
214
|
+
private activeReadPipeline: Pipeline | null = null;
|
|
215
|
+
private activeWritePipeline: Pipeline | null = null;
|
|
216
|
+
private readIndex = 0;
|
|
217
|
+
private writeIndex = 0;
|
|
218
|
+
private redis: Redis;
|
|
219
|
+
pipeline: Pipeline; // only to make sure that proxy can work
|
|
220
|
+
pipelineCounter = 0; // to keep track of how many times a pipeline was executed
|
|
221
|
+
|
|
222
|
+
constructor(redis: Redis) {
|
|
223
|
+
this.redis = redis;
|
|
224
|
+
this.pipeline = redis.pipeline();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async withAutoPipeline<T>(
|
|
228
|
+
commandMode: CommandMode,
|
|
229
|
+
executeWithPipeline: (pipeline: Pipeline) => unknown
|
|
230
|
+
): Promise<T> {
|
|
231
|
+
const isRead = commandMode === "read";
|
|
232
|
+
const activePipeline = isRead ? this.activeReadPipeline : this.activeWritePipeline;
|
|
233
|
+
const pipeline = activePipeline ?? this.redis.pipeline();
|
|
234
|
+
|
|
235
|
+
if (!activePipeline) {
|
|
236
|
+
if (isRead) {
|
|
237
|
+
this.activeReadPipeline = pipeline;
|
|
238
|
+
this.readIndex = 0;
|
|
239
|
+
} else {
|
|
240
|
+
this.activeWritePipeline = pipeline;
|
|
241
|
+
this.writeIndex = 0;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const index = isRead ? this.readIndex++ : this.writeIndex++;
|
|
246
|
+
executeWithPipeline(pipeline);
|
|
247
|
+
|
|
248
|
+
// If pipeline reached max size, close it so next command starts a new pipeline
|
|
249
|
+
if (isRead && this.readIndex >= MAX_PIPELINE_SIZE) {
|
|
250
|
+
this.activeReadPipeline = null;
|
|
251
|
+
} else if (!isRead && this.writeIndex >= MAX_PIPELINE_SIZE) {
|
|
252
|
+
this.activeWritePipeline = null;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const pipelineDone = this.deferExecution().then(() => {
|
|
256
|
+
if (!this.pipelinePromises.has(pipeline)) {
|
|
257
|
+
const pipelinePromise = pipeline.exec({ keepErrors: true });
|
|
258
|
+
this.pipelineCounter += 1;
|
|
259
|
+
|
|
260
|
+
this.pipelinePromises.set(pipeline, pipelinePromise);
|
|
261
|
+
if (this.activeReadPipeline === pipeline) {
|
|
262
|
+
this.activeReadPipeline = null;
|
|
263
|
+
}
|
|
264
|
+
if (this.activeWritePipeline === pipeline) {
|
|
265
|
+
this.activeWritePipeline = null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return this.pipelinePromises.get(pipeline)!;
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const results = (await pipelineDone) as UpstashResponse<T>[];
|
|
273
|
+
const commandResult = results[index];
|
|
274
|
+
if (commandResult.error) {
|
|
275
|
+
throw new UpstashError(`Command failed: ${commandResult.error}`);
|
|
276
|
+
}
|
|
277
|
+
return commandResult.result as T;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private async deferExecution() {
|
|
281
|
+
await Promise.resolve();
|
|
282
|
+
await Promise.resolve();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/append
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/string/append.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class AppendCommand extends Command<number, number> {
|
|
9
|
+
constructor(cmd: [key: string, value: string], opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["append", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the number of occupied slots in an array. A missing key counts as `0`.
|
|
6
|
+
*
|
|
7
|
+
* @see https://upstash.com/docs/redis/commands/array/arcount
|
|
8
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arcount.mdx
|
|
9
|
+
*/
|
|
10
|
+
export class ArCountCommand extends Command<number, number> {
|
|
11
|
+
constructor(cmd: [key: string], opts?: CommandOptions<number, number>) {
|
|
12
|
+
super(["ARCOUNT", ...cmd], opts);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Empties one or more array slots. Later values are not shifted.
|
|
6
|
+
*
|
|
7
|
+
* Returns the number of slots that held a value.
|
|
8
|
+
*
|
|
9
|
+
* @see https://upstash.com/docs/redis/commands/array/ardel
|
|
10
|
+
* @see node_modules/@upstash/redis/docs/commands/array/ardel.mdx
|
|
11
|
+
*/
|
|
12
|
+
export class ArDelCommand extends Command<number, number> {
|
|
13
|
+
constructor(
|
|
14
|
+
cmd: [key: string, ...indexes: (number | string)[]],
|
|
15
|
+
opts?: CommandOptions<number, number>
|
|
16
|
+
) {
|
|
17
|
+
super(["ARDEL", ...cmd], opts);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Empties every occupied slot inside one or more inclusive `[start, end]` ranges.
|
|
6
|
+
*
|
|
7
|
+
* Returns the total number of values removed across all ranges.
|
|
8
|
+
*
|
|
9
|
+
* @see https://upstash.com/docs/redis/commands/array/ardelrange
|
|
10
|
+
* @see node_modules/@upstash/redis/docs/commands/array/ardelrange.mdx
|
|
11
|
+
*/
|
|
12
|
+
export class ArDelRangeCommand extends Command<number, number> {
|
|
13
|
+
constructor(
|
|
14
|
+
[key, ...ranges]: [key: string, ...ranges: [start: number | string, end: number | string][]],
|
|
15
|
+
opts?: CommandOptions<number, number>
|
|
16
|
+
) {
|
|
17
|
+
super(["ARDELRANGE", key, ...ranges.flat()], opts);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the value stored at `index`, or `null` if the slot is empty or the key does not exist.
|
|
6
|
+
*
|
|
7
|
+
* @see https://upstash.com/docs/redis/commands/array/arget
|
|
8
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arget.mdx
|
|
9
|
+
*/
|
|
10
|
+
export class ArGetCommand<TData = string> extends Command<unknown | null, TData | null> {
|
|
11
|
+
constructor(
|
|
12
|
+
cmd: [key: string, index: number | string],
|
|
13
|
+
opts?: CommandOptions<unknown | null, TData | null>
|
|
14
|
+
) {
|
|
15
|
+
super(["ARGET", ...cmd], opts);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns every slot in the inclusive range `[start, end]`, with `null` for empty slots.
|
|
6
|
+
*
|
|
7
|
+
* When `start` is greater than `end`, the values are returned from the higher index down.
|
|
8
|
+
* Ranges wider than 1,000,000 indexes are rejected by the server.
|
|
9
|
+
*
|
|
10
|
+
* @see https://upstash.com/docs/redis/commands/array/argetrange
|
|
11
|
+
* @see node_modules/@upstash/redis/docs/commands/array/argetrange.mdx
|
|
12
|
+
*/
|
|
13
|
+
export class ArGetRangeCommand<TData = string> extends Command<unknown[], (TData | null)[]> {
|
|
14
|
+
constructor(
|
|
15
|
+
cmd: [key: string, start: number | string, end: number | string],
|
|
16
|
+
opts?: CommandOptions<unknown[], (TData | null)[]>
|
|
17
|
+
) {
|
|
18
|
+
super(["ARGETRANGE", ...cmd], opts);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
import { parseResponse } from "../util";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A single `ARGREP` predicate:
|
|
7
|
+
* - `exact`: the whole value equals the pattern
|
|
8
|
+
* - `match`: the value contains the pattern as a substring
|
|
9
|
+
* - `glob`: the value matches a glob pattern (`*` and `?`)
|
|
10
|
+
* - `re`: the value matches a regular expression
|
|
11
|
+
*/
|
|
12
|
+
export type ArGrepPredicate =
|
|
13
|
+
| { exact: string }
|
|
14
|
+
| { match: string }
|
|
15
|
+
| { glob: string }
|
|
16
|
+
| { re: string };
|
|
17
|
+
|
|
18
|
+
export type ArGrepOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* One or more predicates (at most 250).
|
|
21
|
+
*/
|
|
22
|
+
predicates: ArGrepPredicate[];
|
|
23
|
+
/**
|
|
24
|
+
* How to combine several predicates. `OR` (the default) matches a slot when any predicate
|
|
25
|
+
* matches, `AND` requires all of them.
|
|
26
|
+
*/
|
|
27
|
+
combine?: "AND" | "OR" | "and" | "or";
|
|
28
|
+
/**
|
|
29
|
+
* Compare case-insensitively.
|
|
30
|
+
*/
|
|
31
|
+
noCase?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Return `[index, value]` pairs instead of bare indexes.
|
|
34
|
+
*/
|
|
35
|
+
withValues?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Maximum number of matches to return.
|
|
38
|
+
*/
|
|
39
|
+
limit?: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Matching indexes, or `[index, value]` pairs when `withValues` is `true`. Indexes are returned as
|
|
44
|
+
* strings; see `arlen`.
|
|
45
|
+
*/
|
|
46
|
+
export type ArGrepResult<TData, TOpts extends ArGrepOptions> = TOpts extends { withValues: true }
|
|
47
|
+
? [string, TData][]
|
|
48
|
+
: TOpts extends { withValues: false }
|
|
49
|
+
? string[]
|
|
50
|
+
: "withValues" extends keyof TOpts
|
|
51
|
+
? string[] | [string, TData][]
|
|
52
|
+
: string[];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns the indexes in `[start, end]` whose value matches the given predicates, or
|
|
56
|
+
* `[index, value]` pairs with `withValues`. `start` and `end` accept `"-"` and `"+"` for the lowest
|
|
57
|
+
* and highest possible index.
|
|
58
|
+
*
|
|
59
|
+
* @see https://upstash.com/docs/redis/commands/array/argrep
|
|
60
|
+
* @see node_modules/@upstash/redis/docs/commands/array/argrep.mdx
|
|
61
|
+
*/
|
|
62
|
+
export class ArGrepCommand<
|
|
63
|
+
TData = string,
|
|
64
|
+
TOpts extends ArGrepOptions = ArGrepOptions,
|
|
65
|
+
> extends Command<unknown[], ArGrepResult<TData, TOpts>> {
|
|
66
|
+
constructor(
|
|
67
|
+
[key, start, end, opts]: [
|
|
68
|
+
key: string,
|
|
69
|
+
start: number | string,
|
|
70
|
+
end: number | string,
|
|
71
|
+
opts: TOpts,
|
|
72
|
+
],
|
|
73
|
+
cmdOpts?: CommandOptions<unknown[], ArGrepResult<TData, TOpts>>
|
|
74
|
+
) {
|
|
75
|
+
const command: unknown[] = ["ARGREP", key, start, end];
|
|
76
|
+
|
|
77
|
+
for (const predicate of opts.predicates) {
|
|
78
|
+
if ("exact" in predicate) {
|
|
79
|
+
command.push("EXACT", predicate.exact);
|
|
80
|
+
} else if ("match" in predicate) {
|
|
81
|
+
command.push("MATCH", predicate.match);
|
|
82
|
+
} else if ("glob" in predicate) {
|
|
83
|
+
command.push("GLOB", predicate.glob);
|
|
84
|
+
} else {
|
|
85
|
+
command.push("RE", predicate.re);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (opts.combine) {
|
|
89
|
+
command.push(opts.combine.toUpperCase());
|
|
90
|
+
}
|
|
91
|
+
if (opts.noCase) {
|
|
92
|
+
command.push("NOCASE");
|
|
93
|
+
}
|
|
94
|
+
if (opts.withValues) {
|
|
95
|
+
command.push("WITHVALUES");
|
|
96
|
+
}
|
|
97
|
+
if (opts.limit !== undefined) {
|
|
98
|
+
command.push("LIMIT", opts.limit);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
super(command, {
|
|
102
|
+
deserialize: (result) =>
|
|
103
|
+
parseResponse<unknown[]>(result).map((item) =>
|
|
104
|
+
Array.isArray(item) ? [String(item[0]), item[1]] : String(item)
|
|
105
|
+
) as ArGrepResult<TData, TOpts>,
|
|
106
|
+
...cmdOpts,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
export type ArInfoOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Also report per-slice statistics. This walks the whole array.
|
|
7
|
+
*/
|
|
8
|
+
full?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ArInfoResult = {
|
|
12
|
+
/** Highest occupied index plus one, as reported by `arlen`. A string, like every index. */
|
|
13
|
+
len: string;
|
|
14
|
+
/** Number of occupied slots, as reported by `arcount`. */
|
|
15
|
+
count: number;
|
|
16
|
+
/** Number of indexes covered by one slice. */
|
|
17
|
+
sliceSize: number;
|
|
18
|
+
/** Number of slices currently allocated. */
|
|
19
|
+
slices: number;
|
|
20
|
+
/** Number of entries in the slice directory. */
|
|
21
|
+
directorySize: number;
|
|
22
|
+
/** Number of entries in the top-level directory. */
|
|
23
|
+
superDirEntries: number;
|
|
24
|
+
/** Index the next `arinsert` would write to. A string, like every index. */
|
|
25
|
+
nextInsertIndex: string;
|
|
26
|
+
/** Slices stored in dense form. Only with `full`. */
|
|
27
|
+
denseSlices?: number;
|
|
28
|
+
/** Slices stored in sparse form. Only with `full`. */
|
|
29
|
+
sparseSlices?: number;
|
|
30
|
+
/** Average number of values in a dense slice. Only with `full`. */
|
|
31
|
+
avgDenseSize?: number;
|
|
32
|
+
/** Average fill ratio of a dense slice. Only with `full`. */
|
|
33
|
+
avgDenseFill?: number;
|
|
34
|
+
/** Average number of values in a sparse slice. Only with `full`. */
|
|
35
|
+
avgSparseSize?: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type RawArInfo = unknown[] | Record<string, unknown>;
|
|
39
|
+
|
|
40
|
+
function toCamelCase(field: string): string {
|
|
41
|
+
return field.replaceAll(/-([a-z])/g, (_, char: string) => char.toUpperCase());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function deserializeArInfoResponse(result: RawArInfo): ArInfoResult {
|
|
45
|
+
const entries: [unknown, unknown][] = Array.isArray(result)
|
|
46
|
+
? Array.from({ length: Math.floor(result.length / 2) }, (_, i) => [
|
|
47
|
+
result[i * 2],
|
|
48
|
+
result[i * 2 + 1],
|
|
49
|
+
])
|
|
50
|
+
: Object.entries(result);
|
|
51
|
+
|
|
52
|
+
// `len` and `next-insert-index` are indexes and stay strings; the rest are small counts.
|
|
53
|
+
const indexFields = new Set(["len", "nextInsertIndex"]);
|
|
54
|
+
|
|
55
|
+
const info: Record<string, unknown> = {};
|
|
56
|
+
for (const [field, value] of entries) {
|
|
57
|
+
const name = toCamelCase(String(field));
|
|
58
|
+
if (indexFields.has(name)) {
|
|
59
|
+
info[name] = String(value);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const numeric = typeof value === "number" ? value : Number(value);
|
|
63
|
+
info[name] = Number.isNaN(numeric) ? value : numeric;
|
|
64
|
+
}
|
|
65
|
+
return info as ArInfoResult;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Describes how an array is laid out in memory. Throws if the key does not exist.
|
|
70
|
+
*
|
|
71
|
+
* @see https://upstash.com/docs/redis/commands/array/arinfo
|
|
72
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arinfo.mdx
|
|
73
|
+
*/
|
|
74
|
+
export class ArInfoCommand extends Command<RawArInfo, ArInfoResult> {
|
|
75
|
+
constructor(
|
|
76
|
+
[key, opts]: [key: string, opts?: ArInfoOptions],
|
|
77
|
+
cmdOpts?: CommandOptions<RawArInfo, ArInfoResult>
|
|
78
|
+
) {
|
|
79
|
+
const command: unknown[] = ["ARINFO", key];
|
|
80
|
+
if (opts?.full) {
|
|
81
|
+
command.push("FULL");
|
|
82
|
+
}
|
|
83
|
+
super(command, {
|
|
84
|
+
deserialize: deserializeArInfoResponse,
|
|
85
|
+
...cmdOpts,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|