@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
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command.ts";
|
|
2
|
+
import { Command } from "./command.ts";
|
|
3
|
+
|
|
4
|
+
type XGroupCommandType =
|
|
5
|
+
| {
|
|
6
|
+
type: "CREATE";
|
|
7
|
+
group: string;
|
|
8
|
+
id: `$` | string;
|
|
9
|
+
options?: { MKSTREAM?: boolean; ENTRIESREAD?: number };
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
type: "CREATECONSUMER";
|
|
13
|
+
group: string;
|
|
14
|
+
consumer: string;
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
type: "DELCONSUMER";
|
|
18
|
+
group: string;
|
|
19
|
+
consumer: string;
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
type: "DESTROY";
|
|
23
|
+
group: string;
|
|
24
|
+
}
|
|
25
|
+
| {
|
|
26
|
+
type: "SETID";
|
|
27
|
+
group: string;
|
|
28
|
+
id: `$` | string;
|
|
29
|
+
options?: { ENTRIESREAD?: number };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type XGroupReturnType<T extends XGroupCommandType> = T["type"] extends "CREATE"
|
|
33
|
+
? string
|
|
34
|
+
: T["type"] extends "CREATECONSUMER"
|
|
35
|
+
? 0 | 1
|
|
36
|
+
: T["type"] extends "DELCONSUMER"
|
|
37
|
+
? number
|
|
38
|
+
: T["type"] extends "DESTROY"
|
|
39
|
+
? 0 | 1
|
|
40
|
+
: T["type"] extends "SETID"
|
|
41
|
+
? string
|
|
42
|
+
: never;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @see https://redis.io/commands/xgroup
|
|
46
|
+
* @see node_modules/@upstash/redis/docs/commands/stream/xgroup.mdx
|
|
47
|
+
*/
|
|
48
|
+
export class XGroupCommand<TOptions extends XGroupCommandType = XGroupCommandType> extends Command<
|
|
49
|
+
any,
|
|
50
|
+
XGroupReturnType<TOptions>
|
|
51
|
+
> {
|
|
52
|
+
constructor(
|
|
53
|
+
[key, opts]: [key: string, opts: TOptions],
|
|
54
|
+
commandOptions?: CommandOptions<any, any>
|
|
55
|
+
) {
|
|
56
|
+
const command: unknown[] = ["XGROUP"];
|
|
57
|
+
|
|
58
|
+
switch (opts.type) {
|
|
59
|
+
case "CREATE": {
|
|
60
|
+
command.push("CREATE", key, opts.group, opts.id);
|
|
61
|
+
if (opts.options) {
|
|
62
|
+
if (opts.options.MKSTREAM) {
|
|
63
|
+
command.push("MKSTREAM");
|
|
64
|
+
}
|
|
65
|
+
if (opts.options.ENTRIESREAD !== undefined) {
|
|
66
|
+
command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
case "CREATECONSUMER": {
|
|
73
|
+
command.push("CREATECONSUMER", key, opts.group, opts.consumer);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
case "DELCONSUMER": {
|
|
78
|
+
command.push("DELCONSUMER", key, opts.group, opts.consumer);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
case "DESTROY": {
|
|
83
|
+
command.push("DESTROY", key, opts.group);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
case "SETID": {
|
|
88
|
+
command.push("SETID", key, opts.group, opts.id);
|
|
89
|
+
if (opts.options?.ENTRIESREAD !== undefined) {
|
|
90
|
+
command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
default: {
|
|
96
|
+
throw new Error("Invalid XGROUP");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
super(command, commandOptions);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
type XInfoCommands =
|
|
5
|
+
| {
|
|
6
|
+
type: "CONSUMERS";
|
|
7
|
+
group: string;
|
|
8
|
+
}
|
|
9
|
+
| { type: "GROUPS" };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @see https://redis.io/commands/xinfo
|
|
13
|
+
* @see node_modules/@upstash/redis/docs/commands/stream/xinfo.mdx
|
|
14
|
+
*/
|
|
15
|
+
export class XInfoCommand extends Command<number, unknown[]> {
|
|
16
|
+
constructor(
|
|
17
|
+
[key, options]: [key: string, options: XInfoCommands],
|
|
18
|
+
opts?: CommandOptions<number, unknown[]>
|
|
19
|
+
) {
|
|
20
|
+
const cmds: unknown[] = [];
|
|
21
|
+
if (options.type === "CONSUMERS") {
|
|
22
|
+
cmds.push("CONSUMERS", key, options.group);
|
|
23
|
+
} else {
|
|
24
|
+
cmds.push("GROUPS", key);
|
|
25
|
+
}
|
|
26
|
+
super(["XINFO", ...cmds], opts);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/xlen
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/stream/xlen.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class XLenCommand extends Command<number, number> {
|
|
9
|
+
constructor(cmd: [key: string], opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["XLEN", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/xpending
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/stream/xpending.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class XPendingCommand extends Command<unknown[], unknown[]> {
|
|
9
|
+
constructor(
|
|
10
|
+
[key, group, start, end, count, options]: [
|
|
11
|
+
key: string,
|
|
12
|
+
group: string,
|
|
13
|
+
start: string,
|
|
14
|
+
end: string,
|
|
15
|
+
count: number,
|
|
16
|
+
options?: {
|
|
17
|
+
idleTime?: number;
|
|
18
|
+
consumer?: string | string[];
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
opts?: CommandOptions<unknown[], unknown[]>
|
|
22
|
+
) {
|
|
23
|
+
const consumers =
|
|
24
|
+
options?.consumer === undefined
|
|
25
|
+
? []
|
|
26
|
+
: Array.isArray(options.consumer)
|
|
27
|
+
? [...options.consumer]
|
|
28
|
+
: [options.consumer];
|
|
29
|
+
|
|
30
|
+
super(
|
|
31
|
+
[
|
|
32
|
+
"XPENDING",
|
|
33
|
+
key,
|
|
34
|
+
group,
|
|
35
|
+
...(options?.idleTime ? ["IDLE", options.idleTime] : []),
|
|
36
|
+
start,
|
|
37
|
+
end,
|
|
38
|
+
count,
|
|
39
|
+
...consumers,
|
|
40
|
+
],
|
|
41
|
+
opts
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { parseJSON } from "../util";
|
|
2
|
+
import type { CommandOptions } from "./command";
|
|
3
|
+
import { Command } from "./command";
|
|
4
|
+
|
|
5
|
+
function deserialize<TData extends Record<string, Record<string, unknown>>>(
|
|
6
|
+
result: [string, string[]][]
|
|
7
|
+
): TData {
|
|
8
|
+
const obj: Record<string, Record<string, unknown>> = {};
|
|
9
|
+
for (const e of result) {
|
|
10
|
+
for (let i = 0; i < e.length; i += 2) {
|
|
11
|
+
const streamId = e[i] as string;
|
|
12
|
+
const entries = e[i + 1];
|
|
13
|
+
|
|
14
|
+
if (!(streamId in obj)) {
|
|
15
|
+
obj[streamId] = {};
|
|
16
|
+
}
|
|
17
|
+
for (let j = 0; j < entries.length; j += 2) {
|
|
18
|
+
const field = (entries as string[])[j];
|
|
19
|
+
const value = (entries as string[])[j + 1];
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
obj[streamId][field] = parseJSON(value);
|
|
23
|
+
} catch {
|
|
24
|
+
obj[streamId][field] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return obj as TData;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class XRangeCommand<TData extends Record<string, Record<string, unknown>>> extends Command<
|
|
33
|
+
string[][],
|
|
34
|
+
TData
|
|
35
|
+
> {
|
|
36
|
+
constructor(
|
|
37
|
+
[key, start, end, count]: [key: string, start: string, end: string, count?: number],
|
|
38
|
+
opts?: CommandOptions<unknown[], TData[]>
|
|
39
|
+
) {
|
|
40
|
+
const command: unknown[] = ["XRANGE", key, start, end];
|
|
41
|
+
if (typeof count === "number") {
|
|
42
|
+
command.push("COUNT", count);
|
|
43
|
+
}
|
|
44
|
+
super(command, {
|
|
45
|
+
deserialize: (result) => deserialize<any>(result as any),
|
|
46
|
+
...opts,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
export const UNBALANCED_XREAD_ERR =
|
|
5
|
+
"ERR Unbalanced XREAD list of streams: for each stream key an ID or '$' must be specified";
|
|
6
|
+
|
|
7
|
+
type XReadCommandOptions = [
|
|
8
|
+
key: string | string[],
|
|
9
|
+
id: string | string[],
|
|
10
|
+
options?: {
|
|
11
|
+
count?: number;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated block is not yet supported in Upstash Redis
|
|
14
|
+
*/
|
|
15
|
+
blockMS?: number;
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
//This type ensures users have balanced stream keys and stream ids otherwise redis server will throw an error.
|
|
20
|
+
type XReadOptions = XReadCommandOptions extends [infer K, infer I, ...any[]]
|
|
21
|
+
? K extends string
|
|
22
|
+
? I extends string
|
|
23
|
+
? [
|
|
24
|
+
key: string,
|
|
25
|
+
id: string,
|
|
26
|
+
options?: {
|
|
27
|
+
count?: number;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated block is not yet supported in Upstash Redis
|
|
30
|
+
*/
|
|
31
|
+
blockMS?: number;
|
|
32
|
+
},
|
|
33
|
+
]
|
|
34
|
+
: never
|
|
35
|
+
: K extends string[]
|
|
36
|
+
? I extends string[]
|
|
37
|
+
? [
|
|
38
|
+
key: string[],
|
|
39
|
+
id: string[],
|
|
40
|
+
options?: {
|
|
41
|
+
count?: number;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated block is not yet supported in Upstash Redis
|
|
44
|
+
*/
|
|
45
|
+
blockMS?: number;
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
: never
|
|
49
|
+
: never
|
|
50
|
+
: never;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @see https://redis.io/commands/xread
|
|
54
|
+
* @see node_modules/@upstash/redis/docs/commands/stream/xread.mdx
|
|
55
|
+
*/
|
|
56
|
+
export class XReadCommand extends Command<number, unknown[]> {
|
|
57
|
+
constructor([key, id, options]: XReadOptions, opts?: CommandOptions<number, unknown[]>) {
|
|
58
|
+
if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
|
|
59
|
+
throw new Error(UNBALANCED_XREAD_ERR);
|
|
60
|
+
}
|
|
61
|
+
const commands: unknown[] = [];
|
|
62
|
+
|
|
63
|
+
if (typeof options?.count === "number") {
|
|
64
|
+
commands.push("COUNT", options.count);
|
|
65
|
+
}
|
|
66
|
+
if (typeof options?.blockMS === "number") {
|
|
67
|
+
commands.push("BLOCK", options.blockMS);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
commands.push(
|
|
71
|
+
"STREAMS",
|
|
72
|
+
...(Array.isArray(key) ? [...key] : [key]),
|
|
73
|
+
...(Array.isArray(id) ? [...id] : [id])
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
super(["XREAD", ...commands], opts);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
export const UNBALANCED_XREADGROUP_ERR =
|
|
5
|
+
"ERR Unbalanced XREADGROUP list of streams: for each stream key an ID or '$' must be specified";
|
|
6
|
+
|
|
7
|
+
type Options = {
|
|
8
|
+
count?: number;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated block is not yet supported in Upstash Redis
|
|
11
|
+
*/
|
|
12
|
+
blockMS?: number;
|
|
13
|
+
NOACK?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type XReadGroupCommandOptions = [
|
|
16
|
+
group: string,
|
|
17
|
+
consumer: string,
|
|
18
|
+
key: string | string[],
|
|
19
|
+
id: string | string[],
|
|
20
|
+
options?: Options,
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
//This type ensures users have balanced stream keys and stream ids otherwise redis server will throw an error.
|
|
24
|
+
type XReadGroupOptions = XReadGroupCommandOptions extends [
|
|
25
|
+
string,
|
|
26
|
+
string,
|
|
27
|
+
infer TKey,
|
|
28
|
+
infer TId,
|
|
29
|
+
...any[],
|
|
30
|
+
]
|
|
31
|
+
? TKey extends string
|
|
32
|
+
? TId extends string
|
|
33
|
+
? [group: string, consumer: string, key: string, id: string, options?: Options]
|
|
34
|
+
: never
|
|
35
|
+
: TKey extends string[]
|
|
36
|
+
? TId extends string[]
|
|
37
|
+
? [group: string, consumer: string, key: string[], id: string[], options?: Options]
|
|
38
|
+
: never
|
|
39
|
+
: never
|
|
40
|
+
: never;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @see https://redis.io/commands/xreadgroup
|
|
44
|
+
* @see node_modules/@upstash/redis/docs/commands/stream/xreadgroup.mdx
|
|
45
|
+
*/
|
|
46
|
+
export class XReadGroupCommand extends Command<number, unknown[]> {
|
|
47
|
+
constructor(
|
|
48
|
+
[group, consumer, key, id, options]: XReadGroupOptions,
|
|
49
|
+
opts?: CommandOptions<number, unknown[]>
|
|
50
|
+
) {
|
|
51
|
+
if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
|
|
52
|
+
throw new Error(UNBALANCED_XREADGROUP_ERR);
|
|
53
|
+
}
|
|
54
|
+
const commands: unknown[] = [];
|
|
55
|
+
|
|
56
|
+
if (typeof options?.count === "number") {
|
|
57
|
+
commands.push("COUNT", options.count);
|
|
58
|
+
}
|
|
59
|
+
if (typeof options?.blockMS === "number") {
|
|
60
|
+
commands.push("BLOCK", options.blockMS);
|
|
61
|
+
}
|
|
62
|
+
if (typeof options?.NOACK === "boolean" && options.NOACK) {
|
|
63
|
+
commands.push("NOACK");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
commands.push(
|
|
67
|
+
"STREAMS",
|
|
68
|
+
...(Array.isArray(key) ? [...key] : [key]),
|
|
69
|
+
...(Array.isArray(id) ? [...id] : [id])
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
super(["XREADGROUP", "GROUP", group, consumer, ...commands], opts);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { parseJSON } from "../util";
|
|
2
|
+
import type { CommandOptions } from "./command";
|
|
3
|
+
import { Command } from "./command";
|
|
4
|
+
|
|
5
|
+
export class XRevRangeCommand<
|
|
6
|
+
TData extends Record<string, Record<string, unknown>>,
|
|
7
|
+
> extends Command<string[][], TData> {
|
|
8
|
+
constructor(
|
|
9
|
+
[key, end, start, count]: [key: string, end: string, start: string, count?: number],
|
|
10
|
+
opts?: CommandOptions<unknown[], TData[]>
|
|
11
|
+
) {
|
|
12
|
+
const command: unknown[] = ["XREVRANGE", key, end, start];
|
|
13
|
+
if (typeof count === "number") {
|
|
14
|
+
command.push("COUNT", count);
|
|
15
|
+
}
|
|
16
|
+
super(command, {
|
|
17
|
+
deserialize: (result) => deserialize<any>(result as any),
|
|
18
|
+
...opts,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function deserialize<TData extends Record<string, Record<string, unknown>>>(
|
|
24
|
+
result: [string, string[]][]
|
|
25
|
+
): TData {
|
|
26
|
+
const obj: Record<string, Record<string, unknown>> = {};
|
|
27
|
+
for (const e of result) {
|
|
28
|
+
for (let i = 0; i < e.length; i += 2) {
|
|
29
|
+
const streamId = e[i] as string;
|
|
30
|
+
const entries = e[i + 1];
|
|
31
|
+
|
|
32
|
+
if (!(streamId in obj)) {
|
|
33
|
+
obj[streamId] = {};
|
|
34
|
+
}
|
|
35
|
+
for (let j = 0; j < entries.length; j += 2) {
|
|
36
|
+
const field = (entries as string[])[j];
|
|
37
|
+
const value = (entries as string[])[j + 1];
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
obj[streamId][field] = parseJSON(value);
|
|
41
|
+
} catch {
|
|
42
|
+
obj[streamId][field] = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return obj as TData;
|
|
48
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/xtrim
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/stream/xtrim.mdx
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type XTrimOptions = {
|
|
10
|
+
strategy: "MAXLEN" | "MINID";
|
|
11
|
+
exactness?: "~" | "=";
|
|
12
|
+
threshold: number | string;
|
|
13
|
+
limit?: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export class XTrimCommand extends Command<number, number> {
|
|
17
|
+
constructor(
|
|
18
|
+
[key, options]: [key: string, options: XTrimOptions],
|
|
19
|
+
opts?: CommandOptions<number, number>
|
|
20
|
+
) {
|
|
21
|
+
const { limit, strategy, threshold, exactness = "~" } = options;
|
|
22
|
+
|
|
23
|
+
super(["XTRIM", key, strategy, exactness, threshold, ...(limit ? ["LIMIT", limit] : [])], opts);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
type NXAndXXOptions =
|
|
5
|
+
| { nx: true; xx?: never }
|
|
6
|
+
| { nx?: never; xx: true }
|
|
7
|
+
| { nx?: never; xx?: never };
|
|
8
|
+
|
|
9
|
+
type LTAndGTOptions =
|
|
10
|
+
| { lt: true; gt?: never }
|
|
11
|
+
| { lt?: never; gt: true }
|
|
12
|
+
| { lt?: never; gt?: never };
|
|
13
|
+
|
|
14
|
+
export type ZAddCommandOptions = NXAndXXOptions & LTAndGTOptions & { ch?: true } & { incr?: true };
|
|
15
|
+
|
|
16
|
+
type Arg2<TData> = ScoreMember<TData> | ZAddCommandOptions;
|
|
17
|
+
export type ScoreMember<TData> = { score: number; member: TData };
|
|
18
|
+
/**
|
|
19
|
+
* @see https://redis.io/commands/zadd
|
|
20
|
+
* @see node_modules/@upstash/redis/docs/commands/zset/zadd.mdx
|
|
21
|
+
*/
|
|
22
|
+
export class ZAddCommand<TData = string> extends Command<number | null, number | null> {
|
|
23
|
+
constructor(
|
|
24
|
+
[key, arg1, ...arg2]: [string, Arg2<TData>, ...ScoreMember<TData>[]],
|
|
25
|
+
opts?: CommandOptions<number | null, number | null>
|
|
26
|
+
) {
|
|
27
|
+
const command: unknown[] = ["zadd", key];
|
|
28
|
+
if ("nx" in arg1 && arg1.nx) {
|
|
29
|
+
command.push("nx");
|
|
30
|
+
} else if ("xx" in arg1 && arg1.xx) {
|
|
31
|
+
command.push("xx");
|
|
32
|
+
}
|
|
33
|
+
if ("ch" in arg1 && arg1.ch) {
|
|
34
|
+
command.push("ch");
|
|
35
|
+
}
|
|
36
|
+
if ("incr" in arg1 && arg1.incr) {
|
|
37
|
+
command.push("incr");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if ("lt" in arg1 && arg1.lt) {
|
|
41
|
+
command.push("lt");
|
|
42
|
+
} else if ("gt" in arg1 && arg1.gt) {
|
|
43
|
+
command.push("gt");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if ("score" in arg1 && "member" in arg1) {
|
|
47
|
+
command.push(arg1.score, arg1.member);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
command.push(...arg2.flatMap(({ score, member }) => [score, member]));
|
|
51
|
+
|
|
52
|
+
super(command, opts);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/zcard
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/zset/zcard.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class ZCardCommand extends Command<number, number> {
|
|
9
|
+
constructor(cmd: [key: string], opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["zcard", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
/**
|
|
4
|
+
* @see https://redis.io/commands/zcount
|
|
5
|
+
* @see node_modules/@upstash/redis/docs/commands/zset/zcount.mdx
|
|
6
|
+
*/
|
|
7
|
+
export class ZCountCommand extends Command<number, number> {
|
|
8
|
+
constructor(
|
|
9
|
+
cmd: [key: string, min: number | string, max: number | string],
|
|
10
|
+
opts?: CommandOptions<number, number>
|
|
11
|
+
) {
|
|
12
|
+
super(["zcount", ...cmd], opts);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/zdiffstore
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/zset/zdiffstore.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class ZDiffStoreCommand extends Command<number, number> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [destination: string, numkeys: number, ...keys: string[]],
|
|
11
|
+
opts?: CommandOptions<number, number>
|
|
12
|
+
) {
|
|
13
|
+
super(["zdiffstore", ...cmd], opts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
/**
|
|
4
|
+
* @see https://redis.io/commands/zincrby
|
|
5
|
+
* @see node_modules/@upstash/redis/docs/commands/zset/zincrby.mdx
|
|
6
|
+
*/
|
|
7
|
+
export class ZIncrByCommand<TData> extends Command<number, number> {
|
|
8
|
+
constructor(
|
|
9
|
+
cmd: [key: string, increment: number, member: TData],
|
|
10
|
+
opts?: CommandOptions<number, number>
|
|
11
|
+
) {
|
|
12
|
+
super(["zincrby", ...cmd], opts);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
export type ZInterStoreCommandOptions = {
|
|
5
|
+
aggregate?: "sum" | "min" | "max";
|
|
6
|
+
} & (
|
|
7
|
+
| { weight: number; weights?: never }
|
|
8
|
+
| { weight?: never; weights: number[] }
|
|
9
|
+
| { weight?: never; weights?: never }
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @see https://redis.io/commands/zInterstore
|
|
14
|
+
*/
|
|
15
|
+
export class ZInterStoreCommand extends Command<number, number> {
|
|
16
|
+
constructor(
|
|
17
|
+
cmd: [destination: string, numKeys: 1, key: string, opts?: ZInterStoreCommandOptions],
|
|
18
|
+
cmdOpts?: CommandOptions<number, number>
|
|
19
|
+
);
|
|
20
|
+
constructor(
|
|
21
|
+
cmd: [destination: string, numKeys: number, keys: string[], opts?: ZInterStoreCommandOptions],
|
|
22
|
+
cmdOpts?: CommandOptions<number, number>
|
|
23
|
+
);
|
|
24
|
+
constructor(
|
|
25
|
+
[destination, numKeys, keyOrKeys, opts]: [
|
|
26
|
+
destination: string,
|
|
27
|
+
numKeys: number,
|
|
28
|
+
keyOrKeys: string | string[],
|
|
29
|
+
opts?: ZInterStoreCommandOptions,
|
|
30
|
+
],
|
|
31
|
+
cmdOpts?: CommandOptions<number, number>
|
|
32
|
+
) {
|
|
33
|
+
const command: unknown[] = ["zinterstore", destination, numKeys];
|
|
34
|
+
if (Array.isArray(keyOrKeys)) {
|
|
35
|
+
command.push(...keyOrKeys);
|
|
36
|
+
} else {
|
|
37
|
+
command.push(keyOrKeys);
|
|
38
|
+
}
|
|
39
|
+
if (opts) {
|
|
40
|
+
if ("weights" in opts && opts.weights) {
|
|
41
|
+
command.push("weights", ...opts.weights);
|
|
42
|
+
} else if ("weight" in opts && typeof opts.weight === "number") {
|
|
43
|
+
command.push("weights", opts.weight);
|
|
44
|
+
}
|
|
45
|
+
if ("aggregate" in opts) {
|
|
46
|
+
command.push("aggregate", opts.aggregate);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
super(command, cmdOpts);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
/**
|
|
4
|
+
* @see https://redis.io/commands/zlexcount
|
|
5
|
+
* @see node_modules/@upstash/redis/docs/commands/zset/zlexcount.mdx
|
|
6
|
+
*/
|
|
7
|
+
export class ZLexCountCommand extends Command<number, number> {
|
|
8
|
+
constructor(cmd: [key: string, min: string, max: string], opts?: CommandOptions<number, number>) {
|
|
9
|
+
super(["zlexcount", ...cmd], opts);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/zmscore
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/zset/zmscore.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class ZMScoreCommand<TData> extends Command<string[] | null, number[] | null> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [key: string, members: TData[]],
|
|
11
|
+
opts?: CommandOptions<string[] | null, number[] | null>
|
|
12
|
+
) {
|
|
13
|
+
const [key, members] = cmd;
|
|
14
|
+
super(["zmscore", key, ...members], opts);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
/**
|
|
4
|
+
* @see https://redis.io/commands/zpopmax
|
|
5
|
+
* @see node_modules/@upstash/redis/docs/commands/zset/zpopmax.mdx
|
|
6
|
+
*/
|
|
7
|
+
export class ZPopMaxCommand<TData> extends Command<string[], TData[]> {
|
|
8
|
+
constructor(
|
|
9
|
+
[key, count]: [key: string, count?: number],
|
|
10
|
+
opts?: CommandOptions<string[], TData[]>
|
|
11
|
+
) {
|
|
12
|
+
const command: unknown[] = ["zpopmax", key];
|
|
13
|
+
if (typeof count === "number") {
|
|
14
|
+
command.push(count);
|
|
15
|
+
}
|
|
16
|
+
super(command, opts);
|
|
17
|
+
}
|
|
18
|
+
}
|