@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,140 @@
|
|
|
1
|
+
import { parseJSON } from "../util.ts";
|
|
2
|
+
import type { CommandOptions } from "./command.ts";
|
|
3
|
+
import { Command } from "./command.ts";
|
|
4
|
+
|
|
5
|
+
type RadiusOptions = "M" | "KM" | "FT" | "MI";
|
|
6
|
+
type CenterPoint<TMemberType> =
|
|
7
|
+
| {
|
|
8
|
+
type: "FROMMEMBER" | "frommember";
|
|
9
|
+
member: TMemberType;
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
type: "FROMLONLAT" | "fromlonlat";
|
|
13
|
+
coordinate: { lon: number; lat: number };
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type Shape =
|
|
17
|
+
| { type: "BYRADIUS" | "byradius"; radius: number; radiusType: RadiusOptions }
|
|
18
|
+
| {
|
|
19
|
+
type: "BYBOX" | "bybox";
|
|
20
|
+
rect: { width: number; height: number };
|
|
21
|
+
rectType: RadiusOptions;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type GeoSearchCommandOptions = {
|
|
25
|
+
count?: { limit: number; any?: boolean };
|
|
26
|
+
withCoord?: boolean;
|
|
27
|
+
withDist?: boolean;
|
|
28
|
+
withHash?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type OptionMappings = {
|
|
32
|
+
withHash: "hash";
|
|
33
|
+
withCoord: "coord";
|
|
34
|
+
withDist: "dist";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type GeoSearchOptions<TOptions> = {
|
|
38
|
+
[K in keyof TOptions as K extends keyof OptionMappings
|
|
39
|
+
? OptionMappings[K]
|
|
40
|
+
: never]: K extends "withHash"
|
|
41
|
+
? string
|
|
42
|
+
: K extends "withCoord"
|
|
43
|
+
? { long: number; lat: number }
|
|
44
|
+
: K extends "withDist"
|
|
45
|
+
? number
|
|
46
|
+
: never;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type GeoSearchResponse<TOptions, TMemberType> = ({
|
|
50
|
+
member: TMemberType;
|
|
51
|
+
} & GeoSearchOptions<TOptions>)[];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @see https://redis.io/commands/geosearch
|
|
55
|
+
*/
|
|
56
|
+
export class GeoSearchCommand<
|
|
57
|
+
TMemberType = string,
|
|
58
|
+
TOptions extends GeoSearchCommandOptions = GeoSearchCommandOptions,
|
|
59
|
+
> extends Command<any[] | any[][], GeoSearchResponse<TOptions, TMemberType>> {
|
|
60
|
+
constructor(
|
|
61
|
+
[key, centerPoint, shape, order, opts]: [
|
|
62
|
+
key: string,
|
|
63
|
+
centerPoint: CenterPoint<TMemberType>,
|
|
64
|
+
shape: Shape,
|
|
65
|
+
order: "ASC" | "DESC" | "asc" | "desc",
|
|
66
|
+
opts?: TOptions,
|
|
67
|
+
],
|
|
68
|
+
commandOptions?: CommandOptions<any[] | any[][], GeoSearchResponse<TOptions, TMemberType>>
|
|
69
|
+
) {
|
|
70
|
+
const command: unknown[] = ["GEOSEARCH", key];
|
|
71
|
+
|
|
72
|
+
if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
|
|
73
|
+
command.push(centerPoint.type, centerPoint.member);
|
|
74
|
+
}
|
|
75
|
+
if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
|
|
76
|
+
command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (shape.type === "BYRADIUS" || shape.type === "byradius") {
|
|
80
|
+
command.push(shape.type, shape.radius, shape.radiusType);
|
|
81
|
+
}
|
|
82
|
+
if (shape.type === "BYBOX" || shape.type === "bybox") {
|
|
83
|
+
command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
|
|
84
|
+
}
|
|
85
|
+
command.push(order);
|
|
86
|
+
|
|
87
|
+
if (opts?.count) {
|
|
88
|
+
command.push("COUNT", opts.count.limit, ...(opts.count.any ? ["ANY"] : []));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const transform = (result: string[] | string[][]) => {
|
|
92
|
+
if (!opts?.withCoord && !opts?.withDist && !opts?.withHash) {
|
|
93
|
+
return result.map((member) => {
|
|
94
|
+
try {
|
|
95
|
+
return { member: parseJSON(member as string) };
|
|
96
|
+
} catch {
|
|
97
|
+
return { member };
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return result.map((members) => {
|
|
102
|
+
let counter = 1;
|
|
103
|
+
const obj = {} as any;
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
obj.member = parseJSON(members[0]);
|
|
107
|
+
} catch {
|
|
108
|
+
obj.member = members[0];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (opts.withDist) {
|
|
112
|
+
obj.dist = Number.parseFloat(members[counter++]);
|
|
113
|
+
}
|
|
114
|
+
if (opts.withHash) {
|
|
115
|
+
obj.hash = members[counter++].toString();
|
|
116
|
+
}
|
|
117
|
+
if (opts.withCoord) {
|
|
118
|
+
obj.coord = {
|
|
119
|
+
long: Number.parseFloat(members[counter][0]),
|
|
120
|
+
lat: Number.parseFloat(members[counter][1]),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return obj;
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
super(
|
|
128
|
+
[
|
|
129
|
+
...command,
|
|
130
|
+
...(opts?.withCoord ? ["WITHCOORD"] : []),
|
|
131
|
+
...(opts?.withDist ? ["WITHDIST"] : []),
|
|
132
|
+
...(opts?.withHash ? ["WITHHASH"] : []),
|
|
133
|
+
],
|
|
134
|
+
{
|
|
135
|
+
deserialize: transform,
|
|
136
|
+
...commandOptions,
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command.ts";
|
|
2
|
+
import { Command } from "./command.ts";
|
|
3
|
+
|
|
4
|
+
type RadiusOptions = "M" | "KM" | "FT" | "MI";
|
|
5
|
+
type CenterPoint<TMemberType> =
|
|
6
|
+
| {
|
|
7
|
+
type: "FROMMEMBER" | "frommember";
|
|
8
|
+
member: TMemberType;
|
|
9
|
+
}
|
|
10
|
+
| {
|
|
11
|
+
type: "FROMLONLAT" | "fromlonlat";
|
|
12
|
+
coordinate: { lon: number; lat: number };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Shape =
|
|
16
|
+
| { type: "BYRADIUS" | "byradius"; radius: number; radiusType: RadiusOptions }
|
|
17
|
+
| {
|
|
18
|
+
type: "BYBOX" | "bybox";
|
|
19
|
+
rect: { width: number; height: number };
|
|
20
|
+
rectType: RadiusOptions;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type GeoSearchCommandOptions = {
|
|
24
|
+
count?: { limit: number; any?: boolean };
|
|
25
|
+
storeDist?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @see https://redis.io/commands/geosearchstore
|
|
30
|
+
*/
|
|
31
|
+
export class GeoSearchStoreCommand<
|
|
32
|
+
TMemberType = string,
|
|
33
|
+
TOptions extends GeoSearchCommandOptions = GeoSearchCommandOptions,
|
|
34
|
+
> extends Command<any[] | any[][], number> {
|
|
35
|
+
constructor(
|
|
36
|
+
[destination, key, centerPoint, shape, order, opts]: [
|
|
37
|
+
destination: string,
|
|
38
|
+
key: string,
|
|
39
|
+
centerPoint: CenterPoint<TMemberType>,
|
|
40
|
+
shape: Shape,
|
|
41
|
+
order: "ASC" | "DESC" | "asc" | "desc",
|
|
42
|
+
opts?: TOptions,
|
|
43
|
+
],
|
|
44
|
+
commandOptions?: CommandOptions<any[] | any[][], number>
|
|
45
|
+
) {
|
|
46
|
+
const command: unknown[] = ["GEOSEARCHSTORE", destination, key];
|
|
47
|
+
|
|
48
|
+
if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
|
|
49
|
+
command.push(centerPoint.type, centerPoint.member);
|
|
50
|
+
}
|
|
51
|
+
if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
|
|
52
|
+
command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (shape.type === "BYRADIUS" || shape.type === "byradius") {
|
|
56
|
+
command.push(shape.type, shape.radius, shape.radiusType);
|
|
57
|
+
}
|
|
58
|
+
if (shape.type === "BYBOX" || shape.type === "bybox") {
|
|
59
|
+
command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
|
|
60
|
+
}
|
|
61
|
+
command.push(order);
|
|
62
|
+
|
|
63
|
+
if (opts?.count) {
|
|
64
|
+
command.push("COUNT", opts.count.limit, ...(opts.count.any ? ["ANY"] : []));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
super([...command, ...(opts?.storeDist ? ["STOREDIST"] : [])], commandOptions);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/get
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/string/get.mdx
|
|
7
|
+
* Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as
|
|
8
|
+
* true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor
|
|
9
|
+
* to receive raw strings.
|
|
10
|
+
*/
|
|
11
|
+
export class GetCommand<TData = string> extends Command<unknown | null, TData | null> {
|
|
12
|
+
constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>) {
|
|
13
|
+
super(["get", ...cmd], opts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/getbit
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/bitmap/getbit.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class GetBitCommand extends Command<"0" | "1", 0 | 1> {
|
|
9
|
+
constructor(cmd: [key: string, offset: number], opts?: CommandOptions<"0" | "1", 0 | 1>) {
|
|
10
|
+
super(["getbit", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/getdel
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/string/getdel.mdx
|
|
7
|
+
* Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as
|
|
8
|
+
* true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor
|
|
9
|
+
* to receive raw strings.
|
|
10
|
+
*/
|
|
11
|
+
export class GetDelCommand<TData = string> extends Command<unknown | null, TData | null> {
|
|
12
|
+
constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>) {
|
|
13
|
+
super(["getdel", ...cmd], opts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
type GetExCommandOptions =
|
|
5
|
+
| { ex: number; px?: never; exat?: never; pxat?: never; persist?: never }
|
|
6
|
+
| { ex?: never; px: number; exat?: never; pxat?: never; persist?: never }
|
|
7
|
+
| { ex?: never; px?: never; exat: number; pxat?: never; persist?: never }
|
|
8
|
+
| { ex?: never; px?: never; exat?: never; pxat: number; persist?: never }
|
|
9
|
+
| { ex?: never; px?: never; exat?: never; pxat?: never; persist: true }
|
|
10
|
+
| { ex?: never; px?: never; exat?: never; pxat?: never; persist?: never };
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @see https://redis.io/commands/getex
|
|
14
|
+
*/
|
|
15
|
+
export class GetExCommand<TData = string> extends Command<unknown | null, TData | null> {
|
|
16
|
+
constructor(
|
|
17
|
+
[key, opts]: [key: string, opts?: GetExCommandOptions],
|
|
18
|
+
cmdOpts?: CommandOptions<unknown | null, TData | null>
|
|
19
|
+
) {
|
|
20
|
+
const command: unknown[] = ["getex", key];
|
|
21
|
+
if (opts) {
|
|
22
|
+
if ("ex" in opts && typeof opts.ex === "number") {
|
|
23
|
+
command.push("ex", opts.ex);
|
|
24
|
+
} else if ("px" in opts && typeof opts.px === "number") {
|
|
25
|
+
command.push("px", opts.px);
|
|
26
|
+
} else if ("exat" in opts && typeof opts.exat === "number") {
|
|
27
|
+
command.push("exat", opts.exat);
|
|
28
|
+
} else if ("pxat" in opts && typeof opts.pxat === "number") {
|
|
29
|
+
command.push("pxat", opts.pxat);
|
|
30
|
+
} else if ("persist" in opts && opts.persist) {
|
|
31
|
+
command.push("persist");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
super(command, cmdOpts);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/getrange
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/string/getrange.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class GetRangeCommand extends Command<string, string> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [key: string, start: number, end: number],
|
|
11
|
+
opts?: CommandOptions<string, string>
|
|
12
|
+
) {
|
|
13
|
+
super(["getrange", ...cmd], opts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/getset
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/string/getset.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class GetSetCommand<TData = string> extends Command<unknown | null, TData | null> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [key: string, value: TData],
|
|
11
|
+
opts?: CommandOptions<unknown | null, TData | null>
|
|
12
|
+
) {
|
|
13
|
+
super(["getset", ...cmd], opts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/hdel
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hdel.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class HDelCommand extends Command<"0" | "1", 0 | 1> {
|
|
9
|
+
constructor(cmd: [key: string, ...fields: string[]], opts?: CommandOptions<"0" | "1", 0 | 1>) {
|
|
10
|
+
super(["hdel", ...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/hexists
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hexists.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class HExistsCommand extends Command<number, number> {
|
|
9
|
+
constructor(cmd: [key: string, field: string], opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["hexists", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
import type { ExpireOption } from "./expire";
|
|
4
|
+
|
|
5
|
+
export class HExpireCommand extends Command<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]> {
|
|
6
|
+
constructor(
|
|
7
|
+
cmd: [
|
|
8
|
+
key: string,
|
|
9
|
+
fields: (string | number) | (string | number)[],
|
|
10
|
+
seconds: number,
|
|
11
|
+
option?: ExpireOption,
|
|
12
|
+
],
|
|
13
|
+
opts?: CommandOptions<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]>
|
|
14
|
+
) {
|
|
15
|
+
const [key, fields, seconds, option] = cmd;
|
|
16
|
+
const fieldArray = Array.isArray(fields) ? fields : [fields];
|
|
17
|
+
super(
|
|
18
|
+
[
|
|
19
|
+
"hexpire",
|
|
20
|
+
key,
|
|
21
|
+
seconds,
|
|
22
|
+
...(option ? [option] : []),
|
|
23
|
+
"FIELDS",
|
|
24
|
+
fieldArray.length,
|
|
25
|
+
...fieldArray,
|
|
26
|
+
],
|
|
27
|
+
opts
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
import type { ExpireOption } from "./expire";
|
|
4
|
+
|
|
5
|
+
export class HExpireAtCommand extends Command<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]> {
|
|
6
|
+
constructor(
|
|
7
|
+
cmd: [
|
|
8
|
+
key: string,
|
|
9
|
+
fields: (string | number) | (string | number)[],
|
|
10
|
+
timestamp: number,
|
|
11
|
+
option?: ExpireOption,
|
|
12
|
+
],
|
|
13
|
+
opts?: CommandOptions<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]>
|
|
14
|
+
) {
|
|
15
|
+
const [key, fields, timestamp, option] = cmd;
|
|
16
|
+
const fieldArray = Array.isArray(fields) ? fields : [fields];
|
|
17
|
+
super(
|
|
18
|
+
[
|
|
19
|
+
"hexpireat",
|
|
20
|
+
key,
|
|
21
|
+
timestamp,
|
|
22
|
+
...(option ? [option] : []),
|
|
23
|
+
"FIELDS",
|
|
24
|
+
fieldArray.length,
|
|
25
|
+
...fieldArray,
|
|
26
|
+
],
|
|
27
|
+
opts
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
export class HExpireTimeCommand extends Command<number[], number[]> {
|
|
5
|
+
constructor(
|
|
6
|
+
cmd: [key: string, fields: (string | number) | (string | number)[]],
|
|
7
|
+
opts?: CommandOptions<number[], number[]>
|
|
8
|
+
) {
|
|
9
|
+
const [key, fields] = cmd;
|
|
10
|
+
const fieldArray = Array.isArray(fields) ? fields : [fields];
|
|
11
|
+
super(["hexpiretime", key, "FIELDS", fieldArray.length, ...fieldArray], opts);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/hget
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hget.mdx
|
|
7
|
+
* Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as
|
|
8
|
+
* true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor
|
|
9
|
+
* to receive raw strings.
|
|
10
|
+
*/
|
|
11
|
+
export class HGetCommand<TData> extends Command<unknown | null, TData | null> {
|
|
12
|
+
constructor(
|
|
13
|
+
cmd: [key: string, field: string],
|
|
14
|
+
opts?: CommandOptions<unknown | null, TData | null>
|
|
15
|
+
) {
|
|
16
|
+
super(["hget", ...cmd], opts);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { parseJSON } from "../util";
|
|
2
|
+
import type { CommandOptions } from "./command";
|
|
3
|
+
import { Command } from "./command";
|
|
4
|
+
|
|
5
|
+
function deserialize<TData extends Record<string, unknown>>(result: string[]): TData | null {
|
|
6
|
+
if (result.length === 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const obj: Record<string, unknown> = {};
|
|
10
|
+
for (let i = 0; i < result.length; i += 2) {
|
|
11
|
+
const key = result[i];
|
|
12
|
+
const value = result[i + 1];
|
|
13
|
+
try {
|
|
14
|
+
// handle unsafe integer
|
|
15
|
+
const valueIsNumberAndNotSafeInteger =
|
|
16
|
+
!Number.isNaN(Number(value)) && !Number.isSafeInteger(Number(value));
|
|
17
|
+
obj[key] = valueIsNumberAndNotSafeInteger ? value : parseJSON(value);
|
|
18
|
+
} catch {
|
|
19
|
+
obj[key] = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return obj as TData;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @see https://redis.io/commands/hgetall
|
|
27
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hgetall.mdx
|
|
28
|
+
* Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as
|
|
29
|
+
* true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor
|
|
30
|
+
* to receive raw strings.
|
|
31
|
+
* With automaticDeserialization: false, hgetall returns a flat array instead, such as
|
|
32
|
+
* ["text", "123", "version", "1"], and [] for a missing key.
|
|
33
|
+
*/
|
|
34
|
+
export class HGetAllCommand<TData extends Record<string, unknown>> extends Command<
|
|
35
|
+
unknown | null,
|
|
36
|
+
TData | null
|
|
37
|
+
> {
|
|
38
|
+
constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>) {
|
|
39
|
+
super(["hgetall", ...cmd], {
|
|
40
|
+
deserialize: (result) => deserialize<TData>(result as string[]),
|
|
41
|
+
...opts,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
import { deserialize } from "./hmget";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* HGETDEL returns the values of the specified fields and then atomically deletes them from the hash
|
|
7
|
+
* The field values are returned as an object like this:
|
|
8
|
+
* ```ts
|
|
9
|
+
* {[fieldName: string]: T | null}
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* In case all fields are non-existent or the hash doesn't exist, `null` is returned
|
|
13
|
+
*
|
|
14
|
+
* @see https://redis.io/commands/hgetdel
|
|
15
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hgetdel.mdx
|
|
16
|
+
*/
|
|
17
|
+
export class HGetDelCommand<TData extends Record<string, unknown>> extends Command<
|
|
18
|
+
(string | null)[],
|
|
19
|
+
TData | null
|
|
20
|
+
> {
|
|
21
|
+
constructor(
|
|
22
|
+
[key, ...fields]: [key: string, ...fields: (string | number)[]],
|
|
23
|
+
opts?: CommandOptions<(string | null)[], TData | null>
|
|
24
|
+
) {
|
|
25
|
+
super(["hgetdel", key, "FIELDS", fields.length, ...fields], {
|
|
26
|
+
deserialize: (result) => deserialize<TData>(fields.map(String), result),
|
|
27
|
+
...opts,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
import { deserialize } from "./hmget";
|
|
4
|
+
type HGetExCommandOptions =
|
|
5
|
+
| { ex: number; px?: never; exat?: never; pxat?: never; persist?: never }
|
|
6
|
+
| { ex?: never; px: number; exat?: never; pxat?: never; persist?: never }
|
|
7
|
+
| { ex?: never; px?: never; exat: number; pxat?: never; persist?: never }
|
|
8
|
+
| { ex?: never; px?: never; exat?: never; pxat: number; persist?: never }
|
|
9
|
+
| { ex?: never; px?: never; exat?: never; pxat?: never; persist: true };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* HGETEX returns the values of the specified fields and optionally sets their expiration time or TTL
|
|
13
|
+
* The field values are returned as an object like this:
|
|
14
|
+
* ```ts
|
|
15
|
+
* {[fieldName: string]: T | null}
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* In case all fields are non-existent or the hash doesn't exist, `null` is returned
|
|
19
|
+
*
|
|
20
|
+
* @see https://redis.io/commands/hgetex
|
|
21
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hgetex.mdx
|
|
22
|
+
*/
|
|
23
|
+
export class HGetExCommand<TData extends Record<string, unknown>> extends Command<
|
|
24
|
+
(string | null)[],
|
|
25
|
+
TData | null
|
|
26
|
+
> {
|
|
27
|
+
constructor(
|
|
28
|
+
[key, opts, ...fields]: [
|
|
29
|
+
key: string,
|
|
30
|
+
opts: HGetExCommandOptions,
|
|
31
|
+
...fields: (string | number)[],
|
|
32
|
+
],
|
|
33
|
+
cmdOpts?: CommandOptions<(string | null)[], TData | null>
|
|
34
|
+
) {
|
|
35
|
+
const command: (string | number)[] = ["hgetex", key];
|
|
36
|
+
|
|
37
|
+
if ("ex" in opts && typeof opts.ex === "number") {
|
|
38
|
+
command.push("EX", opts.ex);
|
|
39
|
+
} else if ("px" in opts && typeof opts.px === "number") {
|
|
40
|
+
command.push("PX", opts.px);
|
|
41
|
+
} else if ("exat" in opts && typeof opts.exat === "number") {
|
|
42
|
+
command.push("EXAT", opts.exat);
|
|
43
|
+
} else if ("pxat" in opts && typeof opts.pxat === "number") {
|
|
44
|
+
command.push("PXAT", opts.pxat);
|
|
45
|
+
} else if ("persist" in opts && opts.persist) {
|
|
46
|
+
command.push("PERSIST");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
command.push("FIELDS", fields.length, ...fields);
|
|
50
|
+
|
|
51
|
+
super(command, {
|
|
52
|
+
deserialize: (result) => deserialize<TData>(fields.map(String), result),
|
|
53
|
+
...cmdOpts,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/hincrby
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hincrby.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class HIncrByCommand extends Command<number, number> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [key: string, field: string, increment: number],
|
|
11
|
+
opts?: CommandOptions<number, number>
|
|
12
|
+
) {
|
|
13
|
+
super(["hincrby", ...cmd], opts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/hincrbyfloat
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hincrbyfloat.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class HIncrByFloatCommand extends Command<number, number> {
|
|
9
|
+
constructor(
|
|
10
|
+
cmd: [key: string, field: string, increment: number],
|
|
11
|
+
opts?: CommandOptions<number, number>
|
|
12
|
+
) {
|
|
13
|
+
super(["hincrbyfloat", ...cmd], opts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandOptions } from "./command";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://redis.io/commands/hkeys
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hkeys.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class HKeysCommand extends Command<string[], string[]> {
|
|
9
|
+
constructor([key]: [key: string], opts?: CommandOptions<string[], string[]>) {
|
|
10
|
+
super(["hkeys", key], 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/hlen
|
|
6
|
+
* @see node_modules/@upstash/redis/docs/commands/hash/hlen.mdx
|
|
7
|
+
*/
|
|
8
|
+
export class HLenCommand extends Command<number, number> {
|
|
9
|
+
constructor(cmd: [key: string], opts?: CommandOptions<number, number>) {
|
|
10
|
+
super(["hlen", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|