@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,24 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Appends one or more values after the array's append cursor.
|
|
6
|
+
*
|
|
7
|
+
* Returns the index the last value was written to (not the number of values written).
|
|
8
|
+
*
|
|
9
|
+
* Indexes are returned as strings; see `arlen`.
|
|
10
|
+
*
|
|
11
|
+
* @see https://upstash.com/docs/redis/commands/array/arinsert
|
|
12
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arinsert.mdx
|
|
13
|
+
*/
|
|
14
|
+
export class ArInsertCommand<TData = string> extends Command<number | string, string> {
|
|
15
|
+
constructor(
|
|
16
|
+
cmd: [key: string, ...values: TData[]],
|
|
17
|
+
opts?: CommandOptions<number | string, string>
|
|
18
|
+
) {
|
|
19
|
+
super(["ARINSERT", ...cmd], {
|
|
20
|
+
deserialize: String,
|
|
21
|
+
...opts,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
export type ArLastItemsOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Return the newest value first instead of last.
|
|
7
|
+
*/
|
|
8
|
+
rev?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns up to `count` of the most recently appended values, walking backwards from the append
|
|
13
|
+
* cursor. Values come back oldest-first unless `rev` is set.
|
|
14
|
+
*
|
|
15
|
+
* @see https://upstash.com/docs/redis/commands/array/arlastitems
|
|
16
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arlastitems.mdx
|
|
17
|
+
*/
|
|
18
|
+
export class ArLastItemsCommand<TData = string> extends Command<unknown[], (TData | null)[]> {
|
|
19
|
+
constructor(
|
|
20
|
+
[key, count, opts]: [key: string, count: number, opts?: ArLastItemsOptions],
|
|
21
|
+
cmdOpts?: CommandOptions<unknown[], (TData | null)[]>
|
|
22
|
+
) {
|
|
23
|
+
const command: unknown[] = ["ARLASTITEMS", key, count];
|
|
24
|
+
if (opts?.rev) {
|
|
25
|
+
command.push("REV");
|
|
26
|
+
}
|
|
27
|
+
super(command, cmdOpts);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the length of an array: the highest occupied index plus one. A missing key has length `0`.
|
|
6
|
+
*
|
|
7
|
+
* Because arrays are sparse this can be larger than the number of stored values, see `arcount`.
|
|
8
|
+
*
|
|
9
|
+
* Indexes are returned as strings: they run up to 2^64-2, past what a JavaScript number can hold
|
|
10
|
+
* exactly. This matches how the SDK keeps the `scan` cursor a string, and the value can be passed
|
|
11
|
+
* straight back into any command that takes an index.
|
|
12
|
+
*
|
|
13
|
+
* @see https://upstash.com/docs/redis/commands/array/arlen
|
|
14
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arlen.mdx
|
|
15
|
+
*/
|
|
16
|
+
export class ArLenCommand extends Command<number | string, string> {
|
|
17
|
+
constructor(cmd: [key: string], opts?: CommandOptions<number | string, string>) {
|
|
18
|
+
super(["ARLEN", ...cmd], {
|
|
19
|
+
deserialize: String,
|
|
20
|
+
...opts,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the values at several indexes, in the order the indexes were given, with `null` for
|
|
6
|
+
* empty slots.
|
|
7
|
+
*
|
|
8
|
+
* @see https://upstash.com/docs/redis/commands/array/armget
|
|
9
|
+
* @see node_modules/@upstash/redis/docs/commands/array/armget.mdx
|
|
10
|
+
*/
|
|
11
|
+
export class ArMGetCommand<TData = string> extends Command<unknown[], (TData | null)[]> {
|
|
12
|
+
constructor(
|
|
13
|
+
cmd: [key: string, ...indexes: (number | string)[]],
|
|
14
|
+
opts?: CommandOptions<unknown[], (TData | null)[]>
|
|
15
|
+
) {
|
|
16
|
+
super(["ARMGET", ...cmd], opts);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Index-value pairs for `ARMSET`, either as an object (`{ 0: "a", 10: "b" }`) or as a list of
|
|
6
|
+
* `[index, value]` tuples.
|
|
7
|
+
*/
|
|
8
|
+
export type ArMSetValues<TData> = Record<number | string, TData> | [number | string, TData][];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Writes several index-value pairs into an array in one atomic call.
|
|
12
|
+
*
|
|
13
|
+
* Returns the number of slots that were newly occupied. Overwriting an existing value contributes `0`.
|
|
14
|
+
*
|
|
15
|
+
* @see https://upstash.com/docs/redis/commands/array/armset
|
|
16
|
+
* @see node_modules/@upstash/redis/docs/commands/array/armset.mdx
|
|
17
|
+
*/
|
|
18
|
+
export class ArMSetCommand<TData = string> extends Command<number, number> {
|
|
19
|
+
constructor(
|
|
20
|
+
[key, values]: [key: string, values: ArMSetValues<TData>],
|
|
21
|
+
opts?: CommandOptions<number, number>
|
|
22
|
+
) {
|
|
23
|
+
const pairs = Array.isArray(values) ? values : Object.entries(values);
|
|
24
|
+
super(["ARMSET", key, ...pairs.flatMap(([index, value]) => [index, value])], opts);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the index the next `arinsert` would write to, without moving the cursor.
|
|
6
|
+
*
|
|
7
|
+
* Returns `"0"` for a missing key or one that was never appended to, and `null` when the cursor is
|
|
8
|
+
* already at the highest supported index. Indexes are returned as strings; see `arlen`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://upstash.com/docs/redis/commands/array/arnext
|
|
11
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arnext.mdx
|
|
12
|
+
*/
|
|
13
|
+
export class ArNextCommand extends Command<number | string | null, string | null> {
|
|
14
|
+
constructor(cmd: [key: string], opts?: CommandOptions<number | string | null, string | null>) {
|
|
15
|
+
super(["ARNEXT", ...cmd], {
|
|
16
|
+
deserialize: (result) => (result === null ? null : String(result)),
|
|
17
|
+
...opts,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
type ArOpKeyword = "SUM" | "MIN" | "MAX" | "AND" | "OR" | "XOR" | "USED";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reduction applied by `AROP`:
|
|
8
|
+
* - `SUM`, `MIN`, `MAX`: numeric aggregates
|
|
9
|
+
* - `AND`, `OR`, `XOR`: bitwise folds over the values as 64-bit integers
|
|
10
|
+
* - `USED`: number of occupied slots
|
|
11
|
+
* - `{ match: value }`: number of slots whose value equals `value`
|
|
12
|
+
*/
|
|
13
|
+
export type ArOpOperation<TData = string> = ArOpKeyword | Lowercase<ArOpKeyword> | { match: TData };
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Reduces the values in the inclusive range `[start, end]` to a single number on the server.
|
|
17
|
+
*
|
|
18
|
+
* `SUM`, `MIN`, `MAX`, `AND`, `OR` and `XOR` skip non-numeric values and return `null` when the
|
|
19
|
+
* range contains nothing they could use. `USED` and `match` always return a number.
|
|
20
|
+
*
|
|
21
|
+
* Results are returned as JavaScript numbers, so bitwise results beyond `Number.MAX_SAFE_INTEGER`
|
|
22
|
+
* lose precision.
|
|
23
|
+
*
|
|
24
|
+
* @see https://upstash.com/docs/redis/commands/array/arop
|
|
25
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arop.mdx
|
|
26
|
+
*/
|
|
27
|
+
export class ArOpCommand<TData = string> extends Command<string | number | null, number | null> {
|
|
28
|
+
constructor(
|
|
29
|
+
[key, start, end, operation]: [
|
|
30
|
+
key: string,
|
|
31
|
+
start: number | string,
|
|
32
|
+
end: number | string,
|
|
33
|
+
operation: ArOpOperation<TData>,
|
|
34
|
+
],
|
|
35
|
+
opts?: CommandOptions<string | number | null, number | null>
|
|
36
|
+
) {
|
|
37
|
+
const command: unknown[] = ["AROP", key, start, end];
|
|
38
|
+
if (typeof operation === "string") {
|
|
39
|
+
command.push(operation.toUpperCase());
|
|
40
|
+
} else {
|
|
41
|
+
command.push("MATCH", operation.match);
|
|
42
|
+
}
|
|
43
|
+
super(command, {
|
|
44
|
+
deserialize: (result) => (result === null ? null : Number(result)),
|
|
45
|
+
...opts,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Appends values to a fixed-size ring of `size` slots, wrapping back to index `0` and overwriting
|
|
6
|
+
* the oldest values once the ring is full. Calling it with a different `size` reshapes the ring.
|
|
7
|
+
*
|
|
8
|
+
* Returns the index the last value was written to, as a string; see `arlen`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://upstash.com/docs/redis/commands/array/arring
|
|
11
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arring.mdx
|
|
12
|
+
*/
|
|
13
|
+
export class ArRingCommand<TData = string> extends Command<number | string, string> {
|
|
14
|
+
constructor(
|
|
15
|
+
cmd: [key: string, size: number, ...values: TData[]],
|
|
16
|
+
opts?: CommandOptions<number | string, string>
|
|
17
|
+
) {
|
|
18
|
+
super(["ARRING", ...cmd], {
|
|
19
|
+
deserialize: String,
|
|
20
|
+
...opts,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
import { parseResponse } from "../util";
|
|
4
|
+
|
|
5
|
+
export type ArScanOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Maximum number of slots to return.
|
|
8
|
+
*/
|
|
9
|
+
limit?: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns the occupied slots in the inclusive range `[start, end]` as `[index, value]` pairs, in
|
|
14
|
+
* ascending index order. Empty slots are skipped.
|
|
15
|
+
*
|
|
16
|
+
* Indexes are returned as strings; see `arlen`.
|
|
17
|
+
*
|
|
18
|
+
* @see https://upstash.com/docs/redis/commands/array/arscan
|
|
19
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arscan.mdx
|
|
20
|
+
*/
|
|
21
|
+
export class ArScanCommand<TData = string> extends Command<unknown[], [string, TData][]> {
|
|
22
|
+
constructor(
|
|
23
|
+
[key, start, end, opts]: [
|
|
24
|
+
key: string,
|
|
25
|
+
start: number | string,
|
|
26
|
+
end: number | string,
|
|
27
|
+
opts?: ArScanOptions,
|
|
28
|
+
],
|
|
29
|
+
cmdOpts?: CommandOptions<unknown[], [string, TData][]>
|
|
30
|
+
) {
|
|
31
|
+
const command: unknown[] = ["ARSCAN", key, start, end];
|
|
32
|
+
if (opts?.limit !== undefined) {
|
|
33
|
+
command.push("LIMIT", opts.limit);
|
|
34
|
+
}
|
|
35
|
+
super(command, {
|
|
36
|
+
deserialize: (result) =>
|
|
37
|
+
parseResponse<[number | string, TData][]>(result).map(([index, value]) => [
|
|
38
|
+
String(index),
|
|
39
|
+
value,
|
|
40
|
+
]),
|
|
41
|
+
...cmdOpts,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Moves the append cursor so that the next `arinsert` writes to `index`. Stored values are not
|
|
6
|
+
* touched.
|
|
7
|
+
*
|
|
8
|
+
* Returns `1` if the cursor was moved, `0` if the key does not exist.
|
|
9
|
+
*
|
|
10
|
+
* @see https://upstash.com/docs/redis/commands/array/arseek
|
|
11
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arseek.mdx
|
|
12
|
+
*/
|
|
13
|
+
export class ArSeekCommand extends Command<0 | 1, 0 | 1> {
|
|
14
|
+
constructor(cmd: [key: string, index: number | string], opts?: CommandOptions<0 | 1, 0 | 1>) {
|
|
15
|
+
super(["ARSEEK", ...cmd], opts);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Writes one or more values into an array, starting at `index`: the first value goes to `index`,
|
|
6
|
+
* the next to `index + 1`, and so on.
|
|
7
|
+
*
|
|
8
|
+
* Returns the number of slots that were newly occupied. Overwriting an existing value contributes `0`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://upstash.com/docs/redis/commands/array/arset
|
|
11
|
+
* @see node_modules/@upstash/redis/docs/commands/array/arset.mdx
|
|
12
|
+
*/
|
|
13
|
+
export class ArSetCommand<TData = string> extends Command<number, number> {
|
|
14
|
+
constructor(
|
|
15
|
+
cmd: [key: string, index: number | string, ...values: TData[]],
|
|
16
|
+
opts?: CommandOptions<number, number>
|
|
17
|
+
) {
|
|
18
|
+
super(["ARSET", ...cmd], opts);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/bitcount
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/bitmap/bitcount.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class BitCountCommand extends Command<number, number> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [key: string, start?: never, end?: never],
|
|
11
|
+
opts?: CommandOptions<number, number>
|
|
12
|
+
);
|
|
13
|
+
constructor(
|
|
14
|
+
cmd: [key: string, start: number, end: number],
|
|
15
|
+
opts?: CommandOptions<number, number>
|
|
16
|
+
);
|
|
17
|
+
constructor(
|
|
18
|
+
[key, start, end]: [key: string, start?: number, end?: number],
|
|
19
|
+
opts?: CommandOptions<number, number>
|
|
20
|
+
) {
|
|
21
|
+
const command: unknown[] = ["bitcount", key];
|
|
22
|
+
if (typeof start === "number") {
|
|
23
|
+
command.push(start);
|
|
24
|
+
}
|
|
25
|
+
if (typeof end === "number") {
|
|
26
|
+
command.push(end);
|
|
27
|
+
}
|
|
28
|
+
super(command, opts);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Requester } from "../http";
|
|
2
|
+
import { Command, type CommandOptions } from "./command";
|
|
3
|
+
|
|
4
|
+
type SubCommandArgs<TRest extends unknown[] = []> = [
|
|
5
|
+
encoding: string, // u1 - u63 | i1 - i64
|
|
6
|
+
offset: number | string, // <int> | #<int>
|
|
7
|
+
...rest: TRest,
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @see https://redis.io/commands/bitfield
|
|
12
|
+
*/
|
|
13
|
+
export class BitFieldCommand<T = Promise<number[]>> {
|
|
14
|
+
private command: (string | number)[];
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
args: [key: string],
|
|
18
|
+
private client: Requester,
|
|
19
|
+
private opts?: CommandOptions<number[], number[]>,
|
|
20
|
+
private execOperation = (command: Command<number[], number[]>) => command.exec(this.client) as T
|
|
21
|
+
) {
|
|
22
|
+
this.command = ["bitfield", ...args];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private chain(...args: typeof this.command) {
|
|
26
|
+
this.command.push(...args);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get(...args: SubCommandArgs) {
|
|
31
|
+
return this.chain("get", ...args);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
set(...args: SubCommandArgs<[value: number]>) {
|
|
35
|
+
return this.chain("set", ...args);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
incrby(...args: SubCommandArgs<[increment: number]>) {
|
|
39
|
+
return this.chain("incrby", ...args);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
overflow(overflow: "WRAP" | "SAT" | "FAIL") {
|
|
43
|
+
return this.chain("overflow", overflow);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exec() {
|
|
47
|
+
const command = new Command(this.command, this.opts);
|
|
48
|
+
return this.execOperation(command);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/bitop
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/bitmap/bitop.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class BitOpCommand extends Command<number, number> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [op: "and" | "or" | "xor", destinationKey: string, ...sourceKeys: string[]],
|
|
11
|
+
opts?: CommandOptions<number, number>
|
|
12
|
+
);
|
|
13
|
+
constructor(
|
|
14
|
+
cmd: [op: "not", destinationKey: string, sourceKey: string],
|
|
15
|
+
opts?: CommandOptions<number, number>
|
|
16
|
+
);
|
|
17
|
+
constructor(
|
|
18
|
+
cmd: [op: "diff" | "diff1" | "andor", destinationKey: string, x: string, ...y: string[]],
|
|
19
|
+
opts?: CommandOptions<number, number>
|
|
20
|
+
);
|
|
21
|
+
constructor(
|
|
22
|
+
cmd: [op: "one", destinationKey: string, ...sourceKeys: string[]],
|
|
23
|
+
opts?: CommandOptions<number, number>
|
|
24
|
+
);
|
|
25
|
+
constructor(
|
|
26
|
+
cmd: [
|
|
27
|
+
op: "and" | "or" | "xor" | "not" | "diff" | "diff1" | "andor" | "one",
|
|
28
|
+
destinationKey: string,
|
|
29
|
+
...sourceKeys: string[],
|
|
30
|
+
],
|
|
31
|
+
opts?: CommandOptions<number, number>
|
|
32
|
+
) {
|
|
33
|
+
super(["bitop", ...cmd], opts);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/bitpos
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/bitmap/bitpos.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class BitPosCommand extends Command<number, number> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [key: string, bit: 0 | 1, start?: number, end?: number],
|
|
11
|
+
opts?: CommandOptions<number, number>
|
|
12
|
+
) {
|
|
13
|
+
super(["bitpos", ...cmd], opts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
export type ClientSetInfoAttribute = "LIB-NAME" | "lib-name" | "LIB-VER" | "lib-ver";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @see https://redis.io/commands/client-setinfo
|
|
8
|
+
* @see node_modules/@upstash/redis/docs/commands/connection/client_setinfo.mdx
|
|
9
|
+
*/
|
|
10
|
+
export class ClientSetInfoCommand extends Command<string, string> {
|
|
11
|
+
constructor(
|
|
12
|
+
[attribute, value]: [attribute: ClientSetInfoAttribute, value: string],
|
|
13
|
+
opts?: CommandOptions<string, string>
|
|
14
|
+
) {
|
|
15
|
+
super(["CLIENT", "SETINFO", attribute.toUpperCase(), value], opts);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { UpstashError } from "../error";
|
|
2
|
+
import type { Requester } from "../http";
|
|
3
|
+
import { parseResponse } from "../util";
|
|
4
|
+
|
|
5
|
+
type Serialize = (data: unknown) => string | number | boolean;
|
|
6
|
+
type Deserialize<TResult, TData> = (result: TResult) => TData;
|
|
7
|
+
|
|
8
|
+
const defaultSerializer: Serialize = (c: unknown) => {
|
|
9
|
+
switch (typeof c) {
|
|
10
|
+
case "string":
|
|
11
|
+
case "number":
|
|
12
|
+
case "boolean": {
|
|
13
|
+
return c;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
default: {
|
|
17
|
+
return JSON.stringify(c);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type CommandOptions<TResult, TData> = {
|
|
23
|
+
/**
|
|
24
|
+
* Custom deserializer
|
|
25
|
+
*/
|
|
26
|
+
deserialize?: (result: TResult) => TData;
|
|
27
|
+
/**
|
|
28
|
+
* Automatically try to deserialize the returned data from upstash using `JSON.deserialize`
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
automaticDeserialization?: boolean;
|
|
33
|
+
latencyLogging?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Additional headers to be sent with the request
|
|
36
|
+
*/
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Path to append to the URL
|
|
41
|
+
*/
|
|
42
|
+
path?: string[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Options for streaming requests, mainly used for subscribe, monitor commands
|
|
46
|
+
**/
|
|
47
|
+
streamOptions?: {
|
|
48
|
+
/**
|
|
49
|
+
* Callback to be called when a message is received
|
|
50
|
+
*/
|
|
51
|
+
onMessage?: (data: string) => void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Whether the request is streaming
|
|
55
|
+
*/
|
|
56
|
+
isStreaming?: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Signal to abort the request
|
|
60
|
+
*/
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Command offers default (de)serialization and the exec method to all commands.
|
|
66
|
+
*
|
|
67
|
+
* TData represents what the user will enter or receive,
|
|
68
|
+
* TResult is the raw data returned from upstash, which may need to be transformed or parsed.
|
|
69
|
+
*/
|
|
70
|
+
export class Command<TResult, TData> {
|
|
71
|
+
public readonly command: (string | number | boolean)[];
|
|
72
|
+
public readonly serialize: Serialize;
|
|
73
|
+
public readonly deserialize: Deserialize<TResult, TData>;
|
|
74
|
+
protected readonly headers?: Record<string, string>;
|
|
75
|
+
protected readonly path?: string[];
|
|
76
|
+
protected readonly onMessage?: (data: string) => void;
|
|
77
|
+
protected readonly isStreaming: boolean;
|
|
78
|
+
protected readonly signal?: AbortSignal;
|
|
79
|
+
/**
|
|
80
|
+
* Create a new command instance.
|
|
81
|
+
*
|
|
82
|
+
* You can define a custom `deserialize` function. By default we try to deserialize as json.
|
|
83
|
+
*/
|
|
84
|
+
constructor(
|
|
85
|
+
command: (string | boolean | number | unknown)[],
|
|
86
|
+
opts?: CommandOptions<TResult, TData>
|
|
87
|
+
) {
|
|
88
|
+
this.serialize = defaultSerializer;
|
|
89
|
+
this.deserialize =
|
|
90
|
+
opts?.automaticDeserialization === undefined || opts.automaticDeserialization
|
|
91
|
+
? (opts?.deserialize ?? parseResponse)
|
|
92
|
+
: (x) => x as unknown as TData;
|
|
93
|
+
|
|
94
|
+
this.command = command.map((c) => this.serialize(c));
|
|
95
|
+
this.headers = opts?.headers;
|
|
96
|
+
this.path = opts?.path;
|
|
97
|
+
this.onMessage = opts?.streamOptions?.onMessage;
|
|
98
|
+
this.isStreaming = opts?.streamOptions?.isStreaming ?? false;
|
|
99
|
+
this.signal = opts?.streamOptions?.signal;
|
|
100
|
+
|
|
101
|
+
if (opts?.latencyLogging) {
|
|
102
|
+
const originalExec = this.exec.bind(this);
|
|
103
|
+
this.exec = async (client: Requester): Promise<TData> => {
|
|
104
|
+
const start = performance.now();
|
|
105
|
+
const result = await originalExec(client);
|
|
106
|
+
const end = performance.now();
|
|
107
|
+
const loggerResult = (end - start).toFixed(2);
|
|
108
|
+
// eslint-disable-next-line no-console
|
|
109
|
+
console.log(
|
|
110
|
+
`Latency for \u001B[38;2;19;185;39m${this.command[0]
|
|
111
|
+
.toString()
|
|
112
|
+
.toUpperCase()}\u001B[0m: \u001B[38;2;0;255;255m${loggerResult} ms\u001B[0m`
|
|
113
|
+
);
|
|
114
|
+
return result;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Execute the command using a client.
|
|
121
|
+
*/
|
|
122
|
+
public async exec(client: Requester): Promise<TData> {
|
|
123
|
+
const { result, error } = await client.request<TResult>({
|
|
124
|
+
body: this.command,
|
|
125
|
+
path: this.path,
|
|
126
|
+
upstashSyncToken: client.upstashSyncToken,
|
|
127
|
+
headers: this.headers,
|
|
128
|
+
onMessage: this.onMessage,
|
|
129
|
+
isStreaming: this.isStreaming,
|
|
130
|
+
signal: this.signal,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (error) {
|
|
134
|
+
throw new UpstashError(error);
|
|
135
|
+
}
|
|
136
|
+
if (result === undefined) {
|
|
137
|
+
throw new TypeError("Request did not return a result");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return this.deserialize(result);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/copy
|
|
6
|
+
*/
|
|
7
|
+
export class CopyCommand extends Command<number, "COPIED" | "NOT_COPIED"> {
|
|
8
|
+
constructor(
|
|
9
|
+
[key, destinationKey, opts]: [key: string, destinationKey: string, opts?: { replace: boolean }],
|
|
10
|
+
commandOptions?: CommandOptions<number, "COPIED" | "NOT_COPIED">
|
|
11
|
+
) {
|
|
12
|
+
super(["COPY", key, destinationKey, ...(opts?.replace ? ["REPLACE"] : [])], {
|
|
13
|
+
...commandOptions,
|
|
14
|
+
deserialize(result) {
|
|
15
|
+
if (result > 0) {
|
|
16
|
+
return "COPIED";
|
|
17
|
+
}
|
|
18
|
+
return "NOT_COPIED";
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/dbsize
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/server/dbsize.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class DBSizeCommand extends Command<number, number> {
|
|
9
|
+
constructor(opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["dbsize"], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/decr
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/string/decr.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class DecrCommand extends Command<number, number> {
|
|
9
|
+
constructor(cmd: [key: string], opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["decr", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/decrby
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/string/decrby.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class DecrByCommand extends Command<number, number> {
|
|
9
|
+
constructor(cmd: [key: string, decrement: number], opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["decrby", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/del
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/generic/del.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class DelCommand extends Command<number, number> {
|
|
9
|
+
constructor(cmd: [...keys: string[]], opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["del", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|