@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,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HPEXPIRE
|
|
3
|
+
description: Sets an expiration time for a field in a hash in milliseconds.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="fields" type="string | number | (string | number)[]" required>
|
|
13
|
+
The field or list of fields within the hash to set the expiry for.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
<ParamField body="milliseconds" type="number" required>
|
|
17
|
+
The time-to-live (TTL) in milliseconds.
|
|
18
|
+
</ParamField>
|
|
19
|
+
|
|
20
|
+
<ParamField body="option" type="string" optional>
|
|
21
|
+
Optional condition for setting the expiration:
|
|
22
|
+
- `NX`: Set the expiration only if the field does not already have an expiration.
|
|
23
|
+
- `XX`: Set the expiration only if the field already has an expiration.
|
|
24
|
+
- `GT`: Set the expiration only if the new TTL is greater than the current TTL.
|
|
25
|
+
- `LT`: Set the expiration only if the new TTL is less than the current TTL.
|
|
26
|
+
|
|
27
|
+
For more details, see [HPEXPIRE documentation](/redis/commands/hash/hpexpire).
|
|
28
|
+
</ParamField>
|
|
29
|
+
|
|
30
|
+
## Response
|
|
31
|
+
|
|
32
|
+
<ResponseField type="number[]" required>
|
|
33
|
+
A list of integers indicating whether the expiry was successfully set.
|
|
34
|
+
|
|
35
|
+
- `-2` if the field does not exist in the hash or if key doesn't exist.
|
|
36
|
+
- `0` if the expiration was not set due to the condition.
|
|
37
|
+
- `1` if the expiration was successfully set.
|
|
38
|
+
- `2` if called with 0 seconds/milliseconds or a past Unix time.
|
|
39
|
+
|
|
40
|
+
For more details, see [HPEXPIRE documentation](/redis/commands/hash/hpexpire).
|
|
41
|
+
</ResponseField>
|
|
42
|
+
|
|
43
|
+
<RequestExample>
|
|
44
|
+
```ts Example
|
|
45
|
+
await redis.hset("my-key", "my-field", "my-value");
|
|
46
|
+
const expirationSet = await redis.hpexpire("my-key", "my-field", 1000);
|
|
47
|
+
|
|
48
|
+
console.log(expirationSet); // [1]
|
|
49
|
+
```
|
|
50
|
+
</RequestExample>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HPEXPIREAT
|
|
3
|
+
description: Sets an expiration time for field(s) in a hash in milliseconds since the Unix epoch.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="fields" type="string | number | (string | number)[]" required>
|
|
13
|
+
The field(s) to set an expiration time for.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
<ParamField body="timestamp" type="number" required>
|
|
17
|
+
The expiration time as a Unix timestamp in milliseconds.
|
|
18
|
+
</ParamField>
|
|
19
|
+
|
|
20
|
+
<ParamField body="option" type="string" optional>
|
|
21
|
+
Optional condition for setting the expiration:
|
|
22
|
+
- `NX`: Set the expiration only if the field does not already have an expiration.
|
|
23
|
+
- `XX`: Set the expiration only if the field already has an expiration.
|
|
24
|
+
- `GT`: Set the expiration only if the new TTL is greater than the current TTL.
|
|
25
|
+
- `LT`: Set the expiration only if the new TTL is less than the current TTL.
|
|
26
|
+
</ParamField>
|
|
27
|
+
|
|
28
|
+
## Response
|
|
29
|
+
|
|
30
|
+
<ResponseField type="number[]" required>
|
|
31
|
+
A list of integers indicating whether the expiry was successfully set.
|
|
32
|
+
|
|
33
|
+
- `-2` if the field does not exist in the hash or if key doesn't exist.
|
|
34
|
+
- `0` if the expiration was not set due to the condition.
|
|
35
|
+
- `1` if the expiration was successfully set.
|
|
36
|
+
- `2` if called with 0 seconds/milliseconds or a past Unix time.
|
|
37
|
+
|
|
38
|
+
For more details, see [HPEXPIREAT documentation](/redis/commands/hash/hpexpireat).
|
|
39
|
+
</ResponseField>
|
|
40
|
+
|
|
41
|
+
<RequestExample>
|
|
42
|
+
```ts Example
|
|
43
|
+
await redis.hset("my-key", "my-field", "my-value");
|
|
44
|
+
const expirationSet = await redis.hpexpireat("my-key", "my-field", Date.now() + 1000);
|
|
45
|
+
|
|
46
|
+
console.log(expirationSet); // [1]
|
|
47
|
+
```
|
|
48
|
+
</RequestExample>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HPEXPIRETIME
|
|
3
|
+
description: Retrieves the expiration time of a field in a hash in milliseconds.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="fields" type="string | number | (string | number)[]" required>
|
|
13
|
+
The field(s) to retrieve the expiration time for.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
## Response
|
|
17
|
+
|
|
18
|
+
<ResponseField type="integer" required>
|
|
19
|
+
The expiration time in milliseconds since the Unix epoch.
|
|
20
|
+
|
|
21
|
+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
|
|
22
|
+
- `-1` if the field exists but has no associated expiration.
|
|
23
|
+
|
|
24
|
+
For more details, see [HPEXPIRETIME documentation](/redis/commands/hash/hpexpiretime).
|
|
25
|
+
</ResponseField>
|
|
26
|
+
|
|
27
|
+
<RequestExample>
|
|
28
|
+
```ts Example
|
|
29
|
+
await redis.hset("my-key", "my-field", "my-value");
|
|
30
|
+
await redis.hpexpireat("my-key", "my-field", Date.now() + 1000);
|
|
31
|
+
const expireTime = await redis.hpexpiretime("my-key", "my-field");
|
|
32
|
+
|
|
33
|
+
console.log(expireTime); // e.g., 1697059200000
|
|
34
|
+
```
|
|
35
|
+
</RequestExample>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HPTTL
|
|
3
|
+
description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash in milliseconds.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="fields" type="string | number | (string | number)[]" required>
|
|
13
|
+
The field(s) to retrieve the TTL for.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
## Response
|
|
17
|
+
|
|
18
|
+
<ResponseField type="number[]" required>
|
|
19
|
+
The remaining TTL in milliseconds for each field.
|
|
20
|
+
|
|
21
|
+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
|
|
22
|
+
- `-1` if the field exists but has no associated expiration.
|
|
23
|
+
|
|
24
|
+
For more details, see [HPTTL documentation](/redis/commands/hash/hpttl).
|
|
25
|
+
</ResponseField>
|
|
26
|
+
|
|
27
|
+
<RequestExample>
|
|
28
|
+
```ts Example
|
|
29
|
+
await redis.hset("my-key", "my-field", "my-value");
|
|
30
|
+
await redis.hpexpire("my-key", "my-field", 1000);
|
|
31
|
+
const ttl = await redis.hpttl("my-key", "my-field");
|
|
32
|
+
|
|
33
|
+
console.log(ttl); // e.g., [950]
|
|
34
|
+
```
|
|
35
|
+
</RequestExample>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HRANDFIELD
|
|
3
|
+
description: Return a random field from a hash
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="count" type="integer">
|
|
13
|
+
Optionally return more than one field.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
<ParamField body="withValues" type="boolean">
|
|
17
|
+
Return the values of the fields as well.
|
|
18
|
+
</ParamField>
|
|
19
|
+
|
|
20
|
+
## Response
|
|
21
|
+
|
|
22
|
+
<ResponseField type="Record<string, unknown>" required>
|
|
23
|
+
An object containing the fields and their values.
|
|
24
|
+
</ResponseField>
|
|
25
|
+
|
|
26
|
+
<RequestExample>
|
|
27
|
+
```ts Basic
|
|
28
|
+
await redis.hset("key", {
|
|
29
|
+
id: 1,
|
|
30
|
+
username: "chronark",
|
|
31
|
+
name: "andreas"
|
|
32
|
+
});
|
|
33
|
+
const randomField = await redis.hrandfield("key");
|
|
34
|
+
console.log(randomField); // one of "id", "username" or "name"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```ts Multiple Fields
|
|
38
|
+
await redis.hset("key", {
|
|
39
|
+
id: 1,
|
|
40
|
+
username: "chronark",
|
|
41
|
+
name: "andreas",
|
|
42
|
+
});
|
|
43
|
+
const randomFields = await redis.hrandfield("key", 2);
|
|
44
|
+
console.log(randomFields); // ["id", "username"] or any other combination
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```ts With Values
|
|
48
|
+
await redis.hset("key", {
|
|
49
|
+
id: 1,
|
|
50
|
+
username: "chronark",
|
|
51
|
+
name: "andreas",
|
|
52
|
+
});
|
|
53
|
+
const randomFields = await redis.hrandfield("key", 2, true);
|
|
54
|
+
console.log(randomFields); // { id: "1", username: "chronark" } or any other combination
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
</RequestExample>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HSCAN
|
|
3
|
+
description: Scan a hash for fields.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="cursor" type="number">
|
|
13
|
+
The cursor, use `0` in the beginning and then use the returned cursor for subsequent calls.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
<ParamField body="options" type="Object">
|
|
17
|
+
<ParamField body="match" type="string">
|
|
18
|
+
Glob-style pattern to filter by field names.
|
|
19
|
+
</ParamField>
|
|
20
|
+
<ParamField body="count" type="number">
|
|
21
|
+
Number of fields to return per call.
|
|
22
|
+
</ParamField>
|
|
23
|
+
</ParamField>
|
|
24
|
+
|
|
25
|
+
## Response
|
|
26
|
+
|
|
27
|
+
<ResponseField type="[number, string[]]" required>
|
|
28
|
+
The new cursor and the fields array in format `[field, value, field, value]`.
|
|
29
|
+
If the new cursor is `0` the iteration is complete.
|
|
30
|
+
</ResponseField>
|
|
31
|
+
|
|
32
|
+
<RequestExample>
|
|
33
|
+
```ts Basic
|
|
34
|
+
await redis.hset("key", {
|
|
35
|
+
id: 1,
|
|
36
|
+
username: "chronark",
|
|
37
|
+
name: "andreas"
|
|
38
|
+
});
|
|
39
|
+
const [newCursor, fields] = await redis.hscan("key", 0);
|
|
40
|
+
console.log(newCursor); // likely `0` since this is a very small hash
|
|
41
|
+
console.log(fields); // ["id", 1, "username", "chronark", "name", "andreas"]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```ts Match
|
|
45
|
+
await redis.hset("key", {
|
|
46
|
+
id: 1,
|
|
47
|
+
username: "chronark",
|
|
48
|
+
name: "andreas",
|
|
49
|
+
});
|
|
50
|
+
const [newCursor, fields] = await redis.hscan("key", 0, { match: "user*" });
|
|
51
|
+
console.log(newCursor); // likely `0` since this is a very small hash
|
|
52
|
+
console.log(fields); // ["username", "chronark"]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
```ts Count
|
|
57
|
+
await redis.hset("key", {
|
|
58
|
+
id: 1,
|
|
59
|
+
username: "chronark",
|
|
60
|
+
name: "andreas",
|
|
61
|
+
});
|
|
62
|
+
const [newCursor, fields] = await redis.hscan("key", 0, { count: 2 });
|
|
63
|
+
console.log(fields); // ["id", 1, "name", "andreas", "username", "chronark"]
|
|
64
|
+
```
|
|
65
|
+
</RequestExample>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HSET
|
|
3
|
+
description: Write one or more fields to a hash.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="fields" type="{ [fieldName]: TValue }" required>
|
|
13
|
+
An object of fields and their values.
|
|
14
|
+
|
|
15
|
+
</ParamField>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Response
|
|
19
|
+
|
|
20
|
+
<ResponseField type="integer" required>
|
|
21
|
+
The number of fields that were added.
|
|
22
|
+
</ResponseField>
|
|
23
|
+
|
|
24
|
+
<RequestExample>
|
|
25
|
+
```ts Example
|
|
26
|
+
await redis.hset("key", {
|
|
27
|
+
id: 1,
|
|
28
|
+
username: "chronark",
|
|
29
|
+
name: "andreas"
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
</RequestExample>
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HSETEX
|
|
3
|
+
description: Set hash fields with expiration support.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The `HSETEX` command sets the specified fields with their values and optionally sets their expiration time or TTL. It supports conditional operations to control when fields should be set.
|
|
7
|
+
|
|
8
|
+
## Arguments
|
|
9
|
+
|
|
10
|
+
<ParamField body="key" type="string" required>
|
|
11
|
+
The key of the hash.
|
|
12
|
+
</ParamField>
|
|
13
|
+
|
|
14
|
+
<ParamField body="options" type="object">
|
|
15
|
+
Options for conditional setting and expiration.
|
|
16
|
+
|
|
17
|
+
<Expandable title="properties">
|
|
18
|
+
<ParamField body="conditional" type="'FNX' | 'fnx' | 'FXX' | 'fxx'">
|
|
19
|
+
Conditional setting options (case-insensitive):
|
|
20
|
+
- `FNX`: Only set fields if the hash does not exist
|
|
21
|
+
- `FXX`: Only set fields if the hash already exists
|
|
22
|
+
</ParamField>
|
|
23
|
+
|
|
24
|
+
<ParamField body="expiration" type="object">
|
|
25
|
+
Expiration options for the hash.
|
|
26
|
+
|
|
27
|
+
<Expandable title="expiration">
|
|
28
|
+
<ParamField body="ex" type="number">
|
|
29
|
+
Set expiration time in seconds.
|
|
30
|
+
</ParamField>
|
|
31
|
+
|
|
32
|
+
<ParamField body="px" type="number">
|
|
33
|
+
Set expiration time in milliseconds.
|
|
34
|
+
</ParamField>
|
|
35
|
+
|
|
36
|
+
<ParamField body="exat" type="number">
|
|
37
|
+
Set expiration as Unix timestamp in seconds.
|
|
38
|
+
</ParamField>
|
|
39
|
+
|
|
40
|
+
<ParamField body="pxat" type="number">
|
|
41
|
+
Set expiration as Unix timestamp in milliseconds.
|
|
42
|
+
</ParamField>
|
|
43
|
+
|
|
44
|
+
<ParamField body="keepttl" type="true">
|
|
45
|
+
Retain the existing time to live (TTL) associated with the hash key when setting fields. If the hash has an expiration, it will be preserved. Set to `true` to enable.
|
|
46
|
+
</ParamField>
|
|
47
|
+
</Expandable>
|
|
48
|
+
</ParamField>
|
|
49
|
+
</Expandable>
|
|
50
|
+
</ParamField>
|
|
51
|
+
|
|
52
|
+
<ParamField body="fields" type="{ [fieldName]: TValue }" required>
|
|
53
|
+
An object of fields and their values to set.
|
|
54
|
+
</ParamField>
|
|
55
|
+
|
|
56
|
+
## Response
|
|
57
|
+
|
|
58
|
+
<ResponseField type="number" required>
|
|
59
|
+
The number of fields that were set. Returns 0 if conditions are not met (e.g., `conditional: "FNX"` but hash exists, or `conditional: "FXX"` but hash doesn't exist).
|
|
60
|
+
</ResponseField>
|
|
61
|
+
|
|
62
|
+
<RequestExample>
|
|
63
|
+
```ts Basic Example
|
|
64
|
+
// Set fields with 1 hour expiration
|
|
65
|
+
await redis.hsetex("user:123", { expiration: { ex: 3600 } }, {
|
|
66
|
+
name: "John",
|
|
67
|
+
email: "john@example.com"
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```ts With FNX (only if hash doesn't exist)
|
|
72
|
+
// Set fields only if the hash doesn't exist
|
|
73
|
+
const result = await redis.hsetex(
|
|
74
|
+
"user:456",
|
|
75
|
+
{ conditional: "FNX" },
|
|
76
|
+
{ name: "Jane", age: "25" }
|
|
77
|
+
);
|
|
78
|
+
console.log(result); // 2 (if hash didn't exist)
|
|
79
|
+
|
|
80
|
+
// Try again - will return 0 since hash now exists
|
|
81
|
+
const result2 = await redis.hsetex(
|
|
82
|
+
"user:456",
|
|
83
|
+
{ conditional: "FNX" },
|
|
84
|
+
{ email: "jane@example.com" }
|
|
85
|
+
);
|
|
86
|
+
console.log(result2); // 0
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```ts With FXX (only if hash exists)
|
|
90
|
+
// First create the hash
|
|
91
|
+
await redis.hset("session:abc", { token: "xyz" });
|
|
92
|
+
|
|
93
|
+
// Update only if hash exists
|
|
94
|
+
const result = await redis.hsetex(
|
|
95
|
+
"session:abc",
|
|
96
|
+
{ conditional: "FXX" },
|
|
97
|
+
{ user: "john" }
|
|
98
|
+
);
|
|
99
|
+
console.log(result); // 1 (hash exists, field added)
|
|
100
|
+
|
|
101
|
+
// Try on non-existent hash
|
|
102
|
+
const result2 = await redis.hsetex(
|
|
103
|
+
"session:nonexistent",
|
|
104
|
+
{ conditional: "FXX" },
|
|
105
|
+
{ user: "jane" }
|
|
106
|
+
);
|
|
107
|
+
console.log(result2); // 0 (hash doesn't exist)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```ts With PX (milliseconds)
|
|
111
|
+
// Set fields with 30 second expiration
|
|
112
|
+
await redis.hsetex("cache:data", { expiration: { px: 30000 } }, {
|
|
113
|
+
value: "cached data",
|
|
114
|
+
timestamp: Date.now().toString()
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```ts With EXAT (Unix timestamp in seconds)
|
|
119
|
+
// Set expiration to specific timestamp
|
|
120
|
+
const futureTime = Math.floor(Date.now() / 1000) + 7200; // 2 hours from now
|
|
121
|
+
await redis.hsetex("temp:data", { expiration: { exat: futureTime } }, {
|
|
122
|
+
info: "temporary information"
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```ts With PXAT (Unix timestamp in milliseconds)
|
|
127
|
+
// Set expiration to specific timestamp in milliseconds
|
|
128
|
+
const futureTime = Date.now() + 300000; // 5 minutes from now
|
|
129
|
+
await redis.hsetex("session:xyz", { expiration: { pxat: futureTime } }, {
|
|
130
|
+
token: "abc123",
|
|
131
|
+
user: "john"
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```ts Combined: Conditional + Expiration
|
|
136
|
+
// Set fields only if hash doesn't exist, with 1 hour expiration
|
|
137
|
+
await redis.hsetex(
|
|
138
|
+
"user:789",
|
|
139
|
+
{
|
|
140
|
+
conditional: "FNX",
|
|
141
|
+
expiration: { ex: 3600 }
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "Alice",
|
|
145
|
+
email: "alice@example.com",
|
|
146
|
+
created: Date.now().toString()
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```ts With KEEPTTL
|
|
152
|
+
// First set fields with expiration
|
|
153
|
+
await redis.hsetex("cache:data", { expiration: { ex: 300 } }, {
|
|
154
|
+
value: "cached"
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Later update fields while retaining the existing TTL
|
|
158
|
+
const result = await redis.hsetex(
|
|
159
|
+
"cache:data",
|
|
160
|
+
{ expiration: { keepttl: true } },
|
|
161
|
+
{ updated: "yes" }
|
|
162
|
+
);
|
|
163
|
+
console.log(result); // 1
|
|
164
|
+
|
|
165
|
+
// Verify TTL is still 300 seconds (or less if time passed)
|
|
166
|
+
const ttl = await redis.ttl("cache:data");
|
|
167
|
+
console.log(ttl); // Should be > 0 and <= 300 (TTL was retained)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
```ts Without Options
|
|
171
|
+
// Just set fields without expiration or conditions
|
|
172
|
+
await redis.hsetex("data:simple", undefined, {
|
|
173
|
+
field1: "value1",
|
|
174
|
+
field2: "value2"
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
</RequestExample>
|
|
178
|
+
|
|
179
|
+
## Use Cases
|
|
180
|
+
|
|
181
|
+
- **Session Management**: Create sessions with automatic expiration
|
|
182
|
+
- **Cache with TTL**: Store cached data that expires automatically
|
|
183
|
+
- **Temporary Data**: Create temporary records with built-in cleanup
|
|
184
|
+
- **Rate Limiting**: Store rate limit counters with automatic reset
|
|
185
|
+
- **Conditional Updates**: Ensure data consistency with FNX/FXX options
|
|
186
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HSETNX
|
|
3
|
+
description: Write a field to a hash but only if the field does not exist.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="field" type="string" required>
|
|
13
|
+
The name of the field.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
<ParamField body="value" type="TValue" required>
|
|
17
|
+
Any value, if it's not a string it will be serialized to JSON.
|
|
18
|
+
</ParamField>
|
|
19
|
+
|
|
20
|
+
## Response
|
|
21
|
+
|
|
22
|
+
<ResponseField type="integer" required>
|
|
23
|
+
`1` if the field was set, `0` if it already existed.
|
|
24
|
+
</ResponseField>
|
|
25
|
+
|
|
26
|
+
<RequestExample>
|
|
27
|
+
```ts Example
|
|
28
|
+
await redis.hsetnx("key", "id", 1)
|
|
29
|
+
```
|
|
30
|
+
</RequestExample>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HSTRLEN
|
|
3
|
+
description: Returns the string length of a value in a hash.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="field" type="string" required>
|
|
13
|
+
The name of the field.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Response
|
|
19
|
+
|
|
20
|
+
<ResponseField type="integer" required>
|
|
21
|
+
`0` if the hash or field does not exist. Otherwise the length of the string.
|
|
22
|
+
</ResponseField>
|
|
23
|
+
|
|
24
|
+
<RequestExample>
|
|
25
|
+
```ts Example
|
|
26
|
+
const length = await redis.hstrlen("key", "field")
|
|
27
|
+
```
|
|
28
|
+
</RequestExample>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HTTL
|
|
3
|
+
description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash in seconds.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
<ParamField body="fields" type="string | number | (string | number)[]" required>
|
|
13
|
+
The field(s) to retrieve the TTL for.
|
|
14
|
+
</ParamField>
|
|
15
|
+
|
|
16
|
+
## Response
|
|
17
|
+
|
|
18
|
+
<ResponseField type="number[]" required>
|
|
19
|
+
The remaining TTL in seconds for each field.
|
|
20
|
+
|
|
21
|
+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
|
|
22
|
+
- `-1` if the field exists but has no associated expiration.
|
|
23
|
+
|
|
24
|
+
For more details, see [HTTL documentation](/redis/commands/hash/httl).
|
|
25
|
+
</ResponseField>
|
|
26
|
+
|
|
27
|
+
<RequestExample>
|
|
28
|
+
```ts Example
|
|
29
|
+
await redis.hset("my-key", "my-field", "my-value");
|
|
30
|
+
await redis.hexpire("my-key", "my-field", 10);
|
|
31
|
+
const ttl = await redis.httl("my-key", "my-field");
|
|
32
|
+
|
|
33
|
+
console.log(ttl); // e.g., [9]
|
|
34
|
+
```
|
|
35
|
+
</RequestExample>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HVALS
|
|
3
|
+
description: Returns all values in the hash stored at key.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the hash.
|
|
10
|
+
</ParamField>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Response
|
|
15
|
+
|
|
16
|
+
<ResponseField type="unknown[]" required>
|
|
17
|
+
All values in the hash, or an empty list when key does not exist.
|
|
18
|
+
</ResponseField>
|
|
19
|
+
|
|
20
|
+
<RequestExample>
|
|
21
|
+
```ts Example
|
|
22
|
+
await redis.hset("key", {
|
|
23
|
+
field1: "Hello",
|
|
24
|
+
field2: "World",
|
|
25
|
+
})
|
|
26
|
+
const values = await redis.hvals("key")
|
|
27
|
+
console.log(values) // ["Hello", "World"]
|
|
28
|
+
```
|
|
29
|
+
</RequestExample>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: JSON.ARRAPPEND
|
|
3
|
+
description: Append values to the array at path in the JSON document at key.
|
|
4
|
+
---
|
|
5
|
+
<Tip>
|
|
6
|
+
To specify a string as an array value to append, wrap the quoted string with an additional set of single quotes. Example: '"silver"'.
|
|
7
|
+
</Tip>
|
|
8
|
+
|
|
9
|
+
## Arguments
|
|
10
|
+
|
|
11
|
+
<ParamField body="key" type="string" required>
|
|
12
|
+
The key of the json entry.
|
|
13
|
+
</ParamField>
|
|
14
|
+
<ParamField body="path" type="string" required>
|
|
15
|
+
The path of the array. `$` is the root.
|
|
16
|
+
</ParamField>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<ParamField body="value" type="...TValue[]" required>
|
|
21
|
+
One or more values to append to the array.
|
|
22
|
+
</ParamField>
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Response
|
|
26
|
+
|
|
27
|
+
<ResponseField type="integer[]" required>
|
|
28
|
+
The length of the array after the appending.
|
|
29
|
+
</ResponseField>
|
|
30
|
+
|
|
31
|
+
<RequestExample>
|
|
32
|
+
```ts Example
|
|
33
|
+
await redis.json.arrappend("key", "$.path.to.array", "a");
|
|
34
|
+
```
|
|
35
|
+
</RequestExample>
|