@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,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZRANGE
|
|
3
|
+
description: Returns the specified range of elements in the sorted set stored at key.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="key" type="string" required>
|
|
10
|
+
The key to get.
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<ParamField body="min" type="number | string" required>
|
|
15
|
+
The lower bound of the range.
|
|
16
|
+
</ParamField>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<ParamField body="max" type="number | string" required>
|
|
20
|
+
The upper bound of the range.
|
|
21
|
+
</ParamField>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<ParamField body="options" >
|
|
25
|
+
<Expandable>
|
|
26
|
+
<ParamField body="withScores" type="boolean">
|
|
27
|
+
Whether to include the scores in the response.
|
|
28
|
+
</ParamField>
|
|
29
|
+
<ParamField body="rev" type="boolean">
|
|
30
|
+
Whether to reverse the order of the response.
|
|
31
|
+
</ParamField>
|
|
32
|
+
<ParamField body="byScore" type="boolean">
|
|
33
|
+
Whether to use the score as the sort order.
|
|
34
|
+
</ParamField>
|
|
35
|
+
<ParamField body="byLex" type="boolean">
|
|
36
|
+
Whether to use lexicographical ordering.
|
|
37
|
+
</ParamField>
|
|
38
|
+
<ParamField body="offset" type="number">
|
|
39
|
+
The offset to start from.
|
|
40
|
+
</ParamField>
|
|
41
|
+
<ParamField body="count" type="number">
|
|
42
|
+
The number of elements to return.
|
|
43
|
+
</ParamField>
|
|
44
|
+
</Expandable>
|
|
45
|
+
</ParamField>
|
|
46
|
+
|
|
47
|
+
## Response
|
|
48
|
+
|
|
49
|
+
<ResponseField type="TMember[]">
|
|
50
|
+
The values in the specified range.
|
|
51
|
+
|
|
52
|
+
If `withScores` is true, the response will have interleaved members and scores: `[TMember, number, TMember, number, ...]`
|
|
53
|
+
</ResponseField>
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
<RequestExample>
|
|
58
|
+
```ts Example
|
|
59
|
+
await redis.zadd("key",
|
|
60
|
+
{ score: 1, member: "m1" },
|
|
61
|
+
{ score: 2, member: "m2" },
|
|
62
|
+
)
|
|
63
|
+
const res = await redis.zrange("key", 1, 3)
|
|
64
|
+
console.log(res) // ["m2"]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```ts WithScores
|
|
68
|
+
await redis.zadd("key",
|
|
69
|
+
{ score: 1, member: "m1" },
|
|
70
|
+
{ score: 2, member: "m2" },
|
|
71
|
+
)
|
|
72
|
+
const res = await redis.zrange("key", 1, 3, { withScores: true })
|
|
73
|
+
console.log(res) // ["m2", 2]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```ts ByScore
|
|
77
|
+
await redis.zadd("key",
|
|
78
|
+
{ score: 1, member: "m1" },
|
|
79
|
+
{ score: 2, member: "m2" },
|
|
80
|
+
{ score: 3, member: "m3" },
|
|
81
|
+
)
|
|
82
|
+
const res = await redis.zrange("key", 1, 2, { byScore: true })
|
|
83
|
+
console.log(res) // ["m1", "m2"]
|
|
84
|
+
```
|
|
85
|
+
</RequestExample>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZRANK
|
|
3
|
+
description: Returns the rank of a member
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="key" type="string" required>
|
|
10
|
+
The key to get.
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
<ParamField body="member" type="TMember" required>
|
|
14
|
+
The member to get the rank of.
|
|
15
|
+
</ParamField>
|
|
16
|
+
|
|
17
|
+
## Response
|
|
18
|
+
|
|
19
|
+
<ResponseField type="integer" required>
|
|
20
|
+
The rank of the member.
|
|
21
|
+
</ResponseField>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
<RequestExample>
|
|
26
|
+
```ts Example
|
|
27
|
+
const rank = await redis.rank("key", "member");
|
|
28
|
+
```
|
|
29
|
+
</RequestExample>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZREM
|
|
3
|
+
description: Remove one or more members from a sorted set
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="key" type="string" required>
|
|
10
|
+
The key of the sorted set
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<ParamField body="members" type="...TMember[]" required>
|
|
15
|
+
One or more members to remove
|
|
16
|
+
</ParamField>
|
|
17
|
+
## Response
|
|
18
|
+
|
|
19
|
+
<ResponseField required>
|
|
20
|
+
The number of members removed from the sorted set.
|
|
21
|
+
</ResponseField>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
<RequestExample>
|
|
26
|
+
```ts Single
|
|
27
|
+
await redis.zrem("key", "member");
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```ts Multiple
|
|
31
|
+
await redis.zrem("key", "member1", "member2");
|
|
32
|
+
```
|
|
33
|
+
</RequestExample>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZREMRANGEBYLEX
|
|
3
|
+
description: Remove all members in a sorted set between the given lexicographical range.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="key" type="string" required>
|
|
10
|
+
The key of the sorted set
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
<ParamField body="min" type="string" required>
|
|
14
|
+
The minimum lexicographical value to remove.
|
|
15
|
+
</ParamField>
|
|
16
|
+
<ParamField body="max" type="string" required>
|
|
17
|
+
The maximum lexicographical value to remove.
|
|
18
|
+
</ParamField>
|
|
19
|
+
|
|
20
|
+
## Response
|
|
21
|
+
|
|
22
|
+
<ResponseField type="integer" required>
|
|
23
|
+
The number of elements removed from the sorted set.
|
|
24
|
+
</ResponseField>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<RequestExample>
|
|
29
|
+
```ts Example
|
|
30
|
+
await redis.zremrangebylex("key", "alpha", "omega")
|
|
31
|
+
```
|
|
32
|
+
</RequestExample>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZREMRANGEBYRANK
|
|
3
|
+
description: Remove all members in a sorted set between the given ranks.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="key" type="string" required>
|
|
10
|
+
The key of the sorted set
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
<ParamField body="min" type="number" required>
|
|
14
|
+
The minimum rank to remove.
|
|
15
|
+
</ParamField>
|
|
16
|
+
<ParamField body="max" type="number" required>
|
|
17
|
+
The maximum rank to remove.
|
|
18
|
+
</ParamField>
|
|
19
|
+
|
|
20
|
+
## Response
|
|
21
|
+
|
|
22
|
+
<ResponseField type="integer" required>
|
|
23
|
+
The number of elements removed from the sorted set.
|
|
24
|
+
</ResponseField>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<RequestExample>
|
|
29
|
+
```ts Example
|
|
30
|
+
await redis.zremrangebyrank("key", 4, 20)
|
|
31
|
+
```
|
|
32
|
+
</RequestExample>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZREMRANGEBYSCORE
|
|
3
|
+
description: Remove all members in a sorted set between the given scores.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="key" type="string" required>
|
|
10
|
+
The key of the sorted set
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
<ParamField body="min" type="number" required>
|
|
14
|
+
The minimum score to remove.
|
|
15
|
+
</ParamField>
|
|
16
|
+
<ParamField body="max" type="number" required>
|
|
17
|
+
The maximum score to remove.
|
|
18
|
+
</ParamField>
|
|
19
|
+
|
|
20
|
+
## Response
|
|
21
|
+
|
|
22
|
+
<ResponseField type="integer" required>
|
|
23
|
+
The number of elements removed from the sorted set.
|
|
24
|
+
</ResponseField>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<RequestExample>
|
|
29
|
+
```ts Example
|
|
30
|
+
await redis.zremrangebyscore("key", 2, 5)
|
|
31
|
+
```
|
|
32
|
+
</RequestExample>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZREVRANK
|
|
3
|
+
description: Returns the rank of a member in a sorted set, with scores ordered from high to low.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="key" type="string" required>
|
|
10
|
+
The key to get.
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
<ParamField body="member" type="TMember" required>
|
|
14
|
+
The member to get the reverse rank of.
|
|
15
|
+
</ParamField>
|
|
16
|
+
|
|
17
|
+
## Response
|
|
18
|
+
|
|
19
|
+
<ResponseField type="integer" required>
|
|
20
|
+
The reverse rank of the member.
|
|
21
|
+
</ResponseField>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
<RequestExample>
|
|
26
|
+
```ts Example
|
|
27
|
+
const rank = await redis.rank("key", "member");
|
|
28
|
+
```
|
|
29
|
+
</RequestExample>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZSCAN
|
|
3
|
+
description: Scan a sorted set
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Arguments
|
|
7
|
+
|
|
8
|
+
<ParamField body="key" type="string" required>
|
|
9
|
+
The key of the sorted set.
|
|
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 members.
|
|
19
|
+
</ParamField>
|
|
20
|
+
<ParamField body="count" type="number">
|
|
21
|
+
Number of members to return per call.
|
|
22
|
+
</ParamField>
|
|
23
|
+
</ParamField>
|
|
24
|
+
|
|
25
|
+
## Response
|
|
26
|
+
|
|
27
|
+
<ResponseField type="[number, TMember[]]" required>
|
|
28
|
+
The new cursor and the members.
|
|
29
|
+
If the new cursor is `0` the iteration is complete.
|
|
30
|
+
</ResponseField>
|
|
31
|
+
|
|
32
|
+
<RequestExample>
|
|
33
|
+
```ts Example
|
|
34
|
+
await redis.zadd("key",
|
|
35
|
+
{ score: 1, member: "a" },
|
|
36
|
+
{ score: 2, member: "ab" },
|
|
37
|
+
{ score: 3, member: "b" },
|
|
38
|
+
{ score: 4, member: "c" },
|
|
39
|
+
{ score: 5, member: "d" },
|
|
40
|
+
)
|
|
41
|
+
const [newCursor, members] = await redis.zscan("key", 0, { match: "a*"});
|
|
42
|
+
console.log(newCursor); // likely `0` since this is a very small set
|
|
43
|
+
console.log(members); // ["a", "ab"]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```ts withCount
|
|
47
|
+
await redis.zadd("key",
|
|
48
|
+
{ score: 1, member: "a" },
|
|
49
|
+
{ score: 2, member: "ab" },
|
|
50
|
+
{ score: 3, member: "b" },
|
|
51
|
+
{ score: 4, member: "c" },
|
|
52
|
+
{ score: 5, member: "d" },
|
|
53
|
+
)
|
|
54
|
+
const [newCursor, members] = await redis.zscan("key", 0, { match: "a*", count: 1});
|
|
55
|
+
console.log(newCursor); // likely `0` since this is a very small set
|
|
56
|
+
console.log(members); // ["a"]
|
|
57
|
+
```
|
|
58
|
+
</RequestExample>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZSCORE
|
|
3
|
+
description: Returns the scores of a member.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="key" type="string" required>
|
|
10
|
+
The key to get.
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
## Response
|
|
14
|
+
|
|
15
|
+
<ResponseField body="member" type="TMember" required>
|
|
16
|
+
A member of the sortedset.
|
|
17
|
+
</ResponseField>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<RequestExample>
|
|
22
|
+
```ts Example
|
|
23
|
+
|
|
24
|
+
await redis.zadd("key",
|
|
25
|
+
{ score: 1, member: "m1" },
|
|
26
|
+
{ score: 2, member: "m2" },
|
|
27
|
+
{ score: 3, member: "m3" },
|
|
28
|
+
{ score: 4, member: "m4" },
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
const score = await redis.zscore("key", "m2")
|
|
32
|
+
console.log(score) // 2
|
|
33
|
+
```
|
|
34
|
+
</RequestExample>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ZUNIONSTORE
|
|
3
|
+
description: Writes the union between sets to a new key.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="destination" type="string" required>
|
|
10
|
+
The key to write the union to.
|
|
11
|
+
</ParamField>
|
|
12
|
+
|
|
13
|
+
<ParamField body="keys" type="integer" required>
|
|
14
|
+
How many keys to compare.
|
|
15
|
+
</ParamField>
|
|
16
|
+
|
|
17
|
+
<ParamField body="keys" type="string | string[]" required>
|
|
18
|
+
The keys to compare.
|
|
19
|
+
</ParamField>
|
|
20
|
+
|
|
21
|
+
<ParamField body="options">
|
|
22
|
+
<ParamField body="aggregate" type="sum | min | max">
|
|
23
|
+
The aggregation method.
|
|
24
|
+
</ParamField>
|
|
25
|
+
|
|
26
|
+
<ParamField body="weight" type="number">
|
|
27
|
+
The weight to apply to each key.
|
|
28
|
+
</ParamField>
|
|
29
|
+
|
|
30
|
+
<ParamField body="weights" type="number[]">
|
|
31
|
+
The weights to apply to each key.
|
|
32
|
+
</ParamField>
|
|
33
|
+
|
|
34
|
+
</ParamField>
|
|
35
|
+
|
|
36
|
+
## Response
|
|
37
|
+
|
|
38
|
+
<ResponseField required>
|
|
39
|
+
The number of elements in the resulting set.
|
|
40
|
+
</ResponseField>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
<RequestExample>
|
|
45
|
+
```ts Simple
|
|
46
|
+
await redis.zadd(
|
|
47
|
+
"key1",
|
|
48
|
+
{ score: 1, member: "member1" },
|
|
49
|
+
)
|
|
50
|
+
await redis.zadd(
|
|
51
|
+
"key2",
|
|
52
|
+
{ score: 1, member: "member1" },
|
|
53
|
+
{ score: 2, member: "member2" },
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const res = await redis.zunionstore("destination", 2, ["key1", "key2"]);
|
|
57
|
+
console.log(res) // 2
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```ts With Weights
|
|
61
|
+
await redis.zadd(
|
|
62
|
+
"key1",
|
|
63
|
+
{ score: 1, member: "member1" },
|
|
64
|
+
)
|
|
65
|
+
await redis.zadd(
|
|
66
|
+
"key2",
|
|
67
|
+
{ score: 1, member: "member1" },
|
|
68
|
+
{ score: 2, member: "member2" },
|
|
69
|
+
)
|
|
70
|
+
const res = await redis.zunionstore(
|
|
71
|
+
"destination",
|
|
72
|
+
2,
|
|
73
|
+
["key1", "key2"],
|
|
74
|
+
{ weights: [2, 3] },
|
|
75
|
+
);
|
|
76
|
+
console.log(res) // 2
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
```ts Aggregate
|
|
81
|
+
await redis.zadd(
|
|
82
|
+
"key1",
|
|
83
|
+
{ score: 1, member: "member1" },
|
|
84
|
+
)
|
|
85
|
+
await redis.zadd(
|
|
86
|
+
"key2",
|
|
87
|
+
{ score: 1, member: "member1" },
|
|
88
|
+
{ score: 2, member: "member2" },
|
|
89
|
+
)
|
|
90
|
+
const res = await redis.zunionstore(
|
|
91
|
+
"destination",
|
|
92
|
+
2,
|
|
93
|
+
["key1", "key2"],
|
|
94
|
+
{ aggregate: "sum" },
|
|
95
|
+
);
|
|
96
|
+
console.log(res) // 2
|
|
97
|
+
```
|
|
98
|
+
</RequestExample>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Redis TypeScript SDK Deployment
|
|
3
|
+
sidebarTitle: Deployment
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
We support various platforms, such as nodejs, cloudflare and fastly. Platforms
|
|
7
|
+
differ slightly when it comes to environment variables and their `fetch` api.
|
|
8
|
+
Please use the correct import when deploying to special platforms.
|
|
9
|
+
|
|
10
|
+
## Node.js / Browser
|
|
11
|
+
|
|
12
|
+
Examples: Vercel, Netlify, AWS Lambda
|
|
13
|
+
|
|
14
|
+
If you are running on nodejs you can set `UPSTASH_REDIS_REST_URL` and
|
|
15
|
+
`UPSTASH_REDIS_REST_TOKEN` as environment variable and create a redis instance
|
|
16
|
+
like this:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { Redis } from "@upstash/redis"
|
|
20
|
+
|
|
21
|
+
const redis = new Redis({
|
|
22
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
23
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// or load directly from env
|
|
27
|
+
const redis = Redis.fromEnv()
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
<Info>
|
|
31
|
+
If you are running on nodejs v17 and earlier, `fetch` will not be natively
|
|
32
|
+
supported. Platforms like Vercel, Netlify, Deno, Fastly etc. provide a polyfill
|
|
33
|
+
for you. But if you are running on bare node, you need to either specify a
|
|
34
|
+
polyfill yourself or change the import path slightly:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { Redis } from "@upstash/redis/with-fetch";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
</Info>
|
|
41
|
+
|
|
42
|
+
- [Code example](https://github.com/upstash/upstash-redis/blob/main/examples/nodejs)
|
|
43
|
+
|
|
44
|
+
## Cloudflare Workers
|
|
45
|
+
|
|
46
|
+
Cloudflare handles environment variables differently than Node.js. Please add
|
|
47
|
+
`UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` using
|
|
48
|
+
`wrangler secret put ...` or in the cloudflare dashboard.
|
|
49
|
+
|
|
50
|
+
Afterwards you can create a redis instance:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { Redis } from "@upstash/redis/cloudflare"
|
|
54
|
+
|
|
55
|
+
const redis = new Redis({
|
|
56
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
57
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// or load directly from global env
|
|
62
|
+
|
|
63
|
+
// service worker
|
|
64
|
+
const redis = Redis.fromEnv()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
// module worker
|
|
68
|
+
export default {
|
|
69
|
+
async fetch(request: Request, env: Bindings) {
|
|
70
|
+
const redis = Redis.fromEnv(env)
|
|
71
|
+
// ...
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- [Code example](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers)
|
|
77
|
+
- [Code example typescript](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers-with-typescript)
|
|
78
|
+
- [Code example Wrangler 1](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers-with-wrangler-1)
|
|
79
|
+
- [Documentation](https://docs.upstash.com/redis/tutorials/cloudflare_workers_with_redis)
|
|
80
|
+
|
|
81
|
+
## Fastly
|
|
82
|
+
|
|
83
|
+
Fastly introduces a concept called
|
|
84
|
+
[backend](https://developer.fastly.com/reference/api/services/backend/). You
|
|
85
|
+
need to configure a backend in your `fastly.toml`. An example can be found
|
|
86
|
+
[here](https://github.com/upstash/upstash-redis/blob/main/examples/fastly/fastly.toml).
|
|
87
|
+
Until the fastly api stabilizes we recommend creating an instance manually:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { Redis } from "@upstash/redis/fastly"
|
|
91
|
+
|
|
92
|
+
const redis = new Redis({
|
|
93
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
94
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
95
|
+
backend: <BACKEND_NAME>,
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- [Code example](https://github.com/upstash/upstash-redis/tree/main/examples/fastly)
|
|
100
|
+
- [Documentation](https://blog.upstash.com/fastly-compute-edge-with-redis)
|
|
101
|
+
|
|
102
|
+
## Deno
|
|
103
|
+
|
|
104
|
+
Examples: [Deno Deploy](https://deno.com/deploy),
|
|
105
|
+
[Netlify Edge](https://www.netlify.com/products/edge/)
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { Redis } from "npm:@upstash/redis"
|
|
109
|
+
|
|
110
|
+
const redis = new Redis({
|
|
111
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
112
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
// or
|
|
116
|
+
const redis = Redis.fromEnv();
|
|
117
|
+
```
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Developing or Testing
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
When developing or testing your application, you might not want or can not use
|
|
6
|
+
Upstash over the internet. In this case, you can use a community project called
|
|
7
|
+
[Serverless Redis HTTP (SRH)](https://github.com/hiett/serverless-redis-http)
|
|
8
|
+
created by [Scott Hiett](https://x.com/hiettdigital).
|
|
9
|
+
|
|
10
|
+
SRH is a Redis proxy and connection pooler that uses HTTP rather than the Redis
|
|
11
|
+
binary protocol. The aim of this project is to be entirely compatible with
|
|
12
|
+
Upstash, and work with any Upstash supported Redis version.
|
|
13
|
+
|
|
14
|
+
We are working with Scott together to keep SRH up to date with the latest
|
|
15
|
+
Upstash features.
|
|
16
|
+
|
|
17
|
+
## Use cases for SRH:
|
|
18
|
+
|
|
19
|
+
- For usage in your CI pipelines, creating Upstash databases is tedious, or you
|
|
20
|
+
have lots of parallel runs.
|
|
21
|
+
- See [Using in GitHub Actions](#in-github-actions) on how to quickly get SRH
|
|
22
|
+
setup for this context.
|
|
23
|
+
- For usage inside of Kubernetes, or any network whereby the Redis server is not
|
|
24
|
+
exposed to the internet.
|
|
25
|
+
- See [Using in Docker Compose](#via-docker-compose) for the various setup
|
|
26
|
+
options directly using the Docker Container.
|
|
27
|
+
- For local development environments, where you have a local Redis server
|
|
28
|
+
running, or require offline access.
|
|
29
|
+
- See [Using the Docker Command](#via-docker-command), or
|
|
30
|
+
[Using Docker Compose](#via-docker-compose).
|
|
31
|
+
|
|
32
|
+
## Setting up SRH
|
|
33
|
+
|
|
34
|
+
### Via Docker command
|
|
35
|
+
|
|
36
|
+
If you have a locally running Redis server, you can simply start an SRH
|
|
37
|
+
container that connects to it. In this example, SRH will be running on port
|
|
38
|
+
`8080`.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
docker run \
|
|
42
|
+
-it -d -p 8080:80 --name srh \
|
|
43
|
+
-e SRH_MODE=env \
|
|
44
|
+
-e SRH_TOKEN=your_token_here \
|
|
45
|
+
-e SRH_CONNECTION_STRING="redis://your_server_here:6379" \
|
|
46
|
+
hiett/serverless-redis-http:latest
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Via Docker Compose
|
|
50
|
+
|
|
51
|
+
If you wish to run in Kubernetes, this should contain all the basics would need
|
|
52
|
+
to set that up. However, be sure to read the Configuration Options, because you
|
|
53
|
+
can create a setup whereby multiple Redis servers are proxied.
|
|
54
|
+
|
|
55
|
+
```yml
|
|
56
|
+
version: "3"
|
|
57
|
+
services:
|
|
58
|
+
redis:
|
|
59
|
+
image: redis
|
|
60
|
+
ports:
|
|
61
|
+
- "6379:6379"
|
|
62
|
+
serverless-redis-http:
|
|
63
|
+
ports:
|
|
64
|
+
- "8079:80"
|
|
65
|
+
image: hiett/serverless-redis-http:latest
|
|
66
|
+
environment:
|
|
67
|
+
SRH_MODE: env
|
|
68
|
+
SRH_TOKEN: example_token
|
|
69
|
+
SRH_CONNECTION_STRING: "redis://redis:6379" # Using `redis` hostname since they're in the same Docker network.
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### In GitHub Actions
|
|
73
|
+
|
|
74
|
+
SRH works nicely in GitHub Actions because you can run it as a container in a
|
|
75
|
+
job's services. Simply start a Redis server, and then SRH alongside it. You
|
|
76
|
+
don't need to worry about a race condition of the Redis instance not being
|
|
77
|
+
ready, because SRH doesn't create a Redis connection until the first command
|
|
78
|
+
comes in.
|
|
79
|
+
|
|
80
|
+
```yml
|
|
81
|
+
name: Test @upstash/redis compatibility
|
|
82
|
+
on:
|
|
83
|
+
push:
|
|
84
|
+
workflow_dispatch:
|
|
85
|
+
|
|
86
|
+
env:
|
|
87
|
+
SRH_TOKEN: example_token
|
|
88
|
+
|
|
89
|
+
jobs:
|
|
90
|
+
container-job:
|
|
91
|
+
runs-on: ubuntu-latest
|
|
92
|
+
container: denoland/deno
|
|
93
|
+
services:
|
|
94
|
+
redis:
|
|
95
|
+
image: redis/redis-stack-server:6.2.6-v6 # 6.2 is the Upstash compatible Redis version
|
|
96
|
+
srh:
|
|
97
|
+
image: hiett/serverless-redis-http:latest
|
|
98
|
+
env:
|
|
99
|
+
SRH_MODE: env # We are using env mode because we are only connecting to one server.
|
|
100
|
+
SRH_TOKEN: ${{ env.SRH_TOKEN }}
|
|
101
|
+
SRH_CONNECTION_STRING: redis://redis:6379
|
|
102
|
+
|
|
103
|
+
steps:
|
|
104
|
+
# You can place your normal testing steps here. In this example, we are running SRH against the upstash/upstash-redis test suite.
|
|
105
|
+
- name: Checkout code
|
|
106
|
+
uses: actions/checkout@v3
|
|
107
|
+
with:
|
|
108
|
+
repository: upstash/upstash-redis
|
|
109
|
+
|
|
110
|
+
- name: Run @upstash/redis Test Suite
|
|
111
|
+
run: deno test -A ./pkg
|
|
112
|
+
env:
|
|
113
|
+
UPSTASH_REDIS_REST_URL: http://srh:80
|
|
114
|
+
UPSTASH_REDIS_REST_TOKEN: ${{ env.SRH_TOKEN }}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
A huge thanks goes out to [Scott](https://hiett.dev/) for creating this project,
|
|
118
|
+
and for his continued efforts to keep it up to date with Upstash.
|