@upstash/redis 0.0.0-ci.120db276
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/.releaserc +14 -0
- package/LICENSE +21 -0
- package/README.md +361 -0
- package/esm/package.json +3 -0
- package/esm/pkg/commands/append.js +9 -0
- package/esm/pkg/commands/bitcount.js +16 -0
- package/esm/pkg/commands/bitop.js +9 -0
- package/esm/pkg/commands/bitpos.js +9 -0
- package/esm/pkg/commands/command.js +57 -0
- package/esm/pkg/commands/dbsize.js +9 -0
- package/esm/pkg/commands/decr.js +9 -0
- package/esm/pkg/commands/decrby.js +9 -0
- package/esm/pkg/commands/del.js +9 -0
- package/esm/pkg/commands/echo.js +9 -0
- package/esm/pkg/commands/eval.js +9 -0
- package/esm/pkg/commands/evalsha.js +9 -0
- package/esm/pkg/commands/exists.js +9 -0
- package/esm/pkg/commands/expire.js +9 -0
- package/esm/pkg/commands/expireat.js +9 -0
- package/esm/pkg/commands/flushall.js +13 -0
- package/esm/pkg/commands/flushdb.js +13 -0
- package/esm/pkg/commands/get.js +9 -0
- package/esm/pkg/commands/getbit.js +9 -0
- package/esm/pkg/commands/getrange.js +9 -0
- package/esm/pkg/commands/getset.js +9 -0
- package/esm/pkg/commands/hdel.js +9 -0
- package/esm/pkg/commands/hexists.js +9 -0
- package/esm/pkg/commands/hget.js +9 -0
- package/esm/pkg/commands/hgetall.js +33 -0
- package/esm/pkg/commands/hincrby.js +9 -0
- package/esm/pkg/commands/hincrbyfloat.js +9 -0
- package/esm/pkg/commands/hkeys.js +9 -0
- package/esm/pkg/commands/hlen.js +9 -0
- package/esm/pkg/commands/hmget.js +35 -0
- package/esm/pkg/commands/hmset.js +13 -0
- package/esm/pkg/commands/hscan.js +16 -0
- package/esm/pkg/commands/hset.js +13 -0
- package/esm/pkg/commands/hsetnx.js +9 -0
- package/esm/pkg/commands/hstrlen.js +9 -0
- package/esm/pkg/commands/hvals.js +9 -0
- package/esm/pkg/commands/incr.js +9 -0
- package/esm/pkg/commands/incrby.js +9 -0
- package/esm/pkg/commands/incrbyfloat.js +9 -0
- package/esm/pkg/commands/keys.js +9 -0
- package/esm/pkg/commands/lindex.js +6 -0
- package/esm/pkg/commands/linsert.js +6 -0
- package/esm/pkg/commands/llen.js +9 -0
- package/esm/pkg/commands/lpop.js +9 -0
- package/esm/pkg/commands/lpush.js +9 -0
- package/esm/pkg/commands/lpushx.js +9 -0
- package/esm/pkg/commands/lrange.js +6 -0
- package/esm/pkg/commands/lrem.js +6 -0
- package/esm/pkg/commands/lset.js +6 -0
- package/esm/pkg/commands/ltrim.js +6 -0
- package/esm/pkg/commands/mget.js +9 -0
- package/esm/pkg/commands/mod.js +114 -0
- package/esm/pkg/commands/mset.js +12 -0
- package/esm/pkg/commands/msetnx.js +9 -0
- package/esm/pkg/commands/persist.js +9 -0
- package/esm/pkg/commands/pexpire.js +9 -0
- package/esm/pkg/commands/pexpireat.js +9 -0
- package/esm/pkg/commands/ping.js +13 -0
- package/esm/pkg/commands/psetex.js +9 -0
- package/esm/pkg/commands/pttl.js +9 -0
- package/esm/pkg/commands/publish.js +9 -0
- package/esm/pkg/commands/randomkey.js +9 -0
- package/esm/pkg/commands/rename.js +9 -0
- package/esm/pkg/commands/renamenx.js +9 -0
- package/esm/pkg/commands/rpop.js +9 -0
- package/esm/pkg/commands/rpush.js +9 -0
- package/esm/pkg/commands/rpushx.js +9 -0
- package/esm/pkg/commands/sadd.js +9 -0
- package/esm/pkg/commands/scan.js +16 -0
- package/esm/pkg/commands/scard.js +9 -0
- package/esm/pkg/commands/script_exists.js +12 -0
- package/esm/pkg/commands/script_flush.js +16 -0
- package/esm/pkg/commands/script_load.js +9 -0
- package/esm/pkg/commands/sdiff.js +9 -0
- package/esm/pkg/commands/sdiffstore.js +9 -0
- package/esm/pkg/commands/set.js +24 -0
- package/esm/pkg/commands/setbit.js +9 -0
- package/esm/pkg/commands/setex.js +9 -0
- package/esm/pkg/commands/setnx.js +9 -0
- package/esm/pkg/commands/setrange.js +9 -0
- package/esm/pkg/commands/sinter.js +9 -0
- package/esm/pkg/commands/sinterstore.js +9 -0
- package/esm/pkg/commands/sismember.js +9 -0
- package/esm/pkg/commands/smembers.js +9 -0
- package/esm/pkg/commands/smove.js +9 -0
- package/esm/pkg/commands/spop.js +13 -0
- package/esm/pkg/commands/srandmember.js +13 -0
- package/esm/pkg/commands/srem.js +9 -0
- package/esm/pkg/commands/sscan.js +16 -0
- package/esm/pkg/commands/strlen.js +9 -0
- package/esm/pkg/commands/sunion.js +9 -0
- package/esm/pkg/commands/sunionstore.js +9 -0
- package/esm/pkg/commands/time.js +9 -0
- package/esm/pkg/commands/touch.js +9 -0
- package/esm/pkg/commands/ttl.js +9 -0
- package/esm/pkg/commands/type.js +9 -0
- package/esm/pkg/commands/unlink.js +9 -0
- package/esm/pkg/commands/zadd.js +26 -0
- package/esm/pkg/commands/zcard.js +9 -0
- package/esm/pkg/commands/zcount.js +9 -0
- package/esm/pkg/commands/zincrby.js +9 -0
- package/esm/pkg/commands/zinterstore.js +27 -0
- package/esm/pkg/commands/zlexcount.js +9 -0
- package/esm/pkg/commands/zpopmax.js +13 -0
- package/esm/pkg/commands/zpopmin.js +13 -0
- package/esm/pkg/commands/zrange.js +20 -0
- package/esm/pkg/commands/zrank.js +9 -0
- package/esm/pkg/commands/zrem.js +9 -0
- package/esm/pkg/commands/zremrangebylex.js +9 -0
- package/esm/pkg/commands/zremrangebyrank.js +9 -0
- package/esm/pkg/commands/zremrangebyscore.js +9 -0
- package/esm/pkg/commands/zrevrank.js +9 -0
- package/esm/pkg/commands/zscan.js +16 -0
- package/esm/pkg/commands/zscore.js +9 -0
- package/esm/pkg/commands/zunionstore.js +27 -0
- package/esm/pkg/error.js +9 -0
- package/esm/pkg/http.js +77 -0
- package/esm/pkg/pipeline.js +1125 -0
- package/esm/pkg/redis.js +1067 -0
- package/esm/pkg/types.js +1 -0
- package/esm/pkg/util.js +31 -0
- package/esm/platforms/cloudflare.js +62 -0
- package/esm/platforms/fastly.js +40 -0
- package/esm/platforms/node_with_fetch.js +60 -0
- package/esm/platforms/nodejs.js +59 -0
- package/package.json +101 -0
- package/script/package.json +3 -0
- package/script/pkg/commands/append.js +13 -0
- package/script/pkg/commands/bitcount.js +20 -0
- package/script/pkg/commands/bitop.js +13 -0
- package/script/pkg/commands/bitpos.js +13 -0
- package/script/pkg/commands/command.js +61 -0
- package/script/pkg/commands/dbsize.js +13 -0
- package/script/pkg/commands/decr.js +13 -0
- package/script/pkg/commands/decrby.js +13 -0
- package/script/pkg/commands/del.js +13 -0
- package/script/pkg/commands/echo.js +13 -0
- package/script/pkg/commands/eval.js +13 -0
- package/script/pkg/commands/evalsha.js +13 -0
- package/script/pkg/commands/exists.js +13 -0
- package/script/pkg/commands/expire.js +13 -0
- package/script/pkg/commands/expireat.js +13 -0
- package/script/pkg/commands/flushall.js +17 -0
- package/script/pkg/commands/flushdb.js +17 -0
- package/script/pkg/commands/get.js +13 -0
- package/script/pkg/commands/getbit.js +13 -0
- package/script/pkg/commands/getrange.js +13 -0
- package/script/pkg/commands/getset.js +13 -0
- package/script/pkg/commands/hdel.js +13 -0
- package/script/pkg/commands/hexists.js +13 -0
- package/script/pkg/commands/hget.js +13 -0
- package/script/pkg/commands/hgetall.js +37 -0
- package/script/pkg/commands/hincrby.js +13 -0
- package/script/pkg/commands/hincrbyfloat.js +13 -0
- package/script/pkg/commands/hkeys.js +13 -0
- package/script/pkg/commands/hlen.js +13 -0
- package/script/pkg/commands/hmget.js +39 -0
- package/script/pkg/commands/hmset.js +17 -0
- package/script/pkg/commands/hscan.js +20 -0
- package/script/pkg/commands/hset.js +17 -0
- package/script/pkg/commands/hsetnx.js +13 -0
- package/script/pkg/commands/hstrlen.js +13 -0
- package/script/pkg/commands/hvals.js +13 -0
- package/script/pkg/commands/incr.js +13 -0
- package/script/pkg/commands/incrby.js +13 -0
- package/script/pkg/commands/incrbyfloat.js +13 -0
- package/script/pkg/commands/keys.js +13 -0
- package/script/pkg/commands/lindex.js +10 -0
- package/script/pkg/commands/linsert.js +10 -0
- package/script/pkg/commands/llen.js +13 -0
- package/script/pkg/commands/lpop.js +13 -0
- package/script/pkg/commands/lpush.js +13 -0
- package/script/pkg/commands/lpushx.js +13 -0
- package/script/pkg/commands/lrange.js +10 -0
- package/script/pkg/commands/lrem.js +10 -0
- package/script/pkg/commands/lset.js +10 -0
- package/script/pkg/commands/ltrim.js +10 -0
- package/script/pkg/commands/mget.js +13 -0
- package/script/pkg/commands/mod.js +130 -0
- package/script/pkg/commands/mset.js +16 -0
- package/script/pkg/commands/msetnx.js +13 -0
- package/script/pkg/commands/persist.js +13 -0
- package/script/pkg/commands/pexpire.js +13 -0
- package/script/pkg/commands/pexpireat.js +13 -0
- package/script/pkg/commands/ping.js +17 -0
- package/script/pkg/commands/psetex.js +13 -0
- package/script/pkg/commands/pttl.js +13 -0
- package/script/pkg/commands/publish.js +13 -0
- package/script/pkg/commands/randomkey.js +13 -0
- package/script/pkg/commands/rename.js +13 -0
- package/script/pkg/commands/renamenx.js +13 -0
- package/script/pkg/commands/rpop.js +13 -0
- package/script/pkg/commands/rpush.js +13 -0
- package/script/pkg/commands/rpushx.js +13 -0
- package/script/pkg/commands/sadd.js +13 -0
- package/script/pkg/commands/scan.js +20 -0
- package/script/pkg/commands/scard.js +13 -0
- package/script/pkg/commands/script_exists.js +16 -0
- package/script/pkg/commands/script_flush.js +20 -0
- package/script/pkg/commands/script_load.js +13 -0
- package/script/pkg/commands/sdiff.js +13 -0
- package/script/pkg/commands/sdiffstore.js +13 -0
- package/script/pkg/commands/set.js +28 -0
- package/script/pkg/commands/setbit.js +13 -0
- package/script/pkg/commands/setex.js +13 -0
- package/script/pkg/commands/setnx.js +13 -0
- package/script/pkg/commands/setrange.js +13 -0
- package/script/pkg/commands/sinter.js +13 -0
- package/script/pkg/commands/sinterstore.js +13 -0
- package/script/pkg/commands/sismember.js +13 -0
- package/script/pkg/commands/smembers.js +13 -0
- package/script/pkg/commands/smove.js +13 -0
- package/script/pkg/commands/spop.js +17 -0
- package/script/pkg/commands/srandmember.js +17 -0
- package/script/pkg/commands/srem.js +13 -0
- package/script/pkg/commands/sscan.js +20 -0
- package/script/pkg/commands/strlen.js +13 -0
- package/script/pkg/commands/sunion.js +13 -0
- package/script/pkg/commands/sunionstore.js +13 -0
- package/script/pkg/commands/time.js +13 -0
- package/script/pkg/commands/touch.js +13 -0
- package/script/pkg/commands/ttl.js +13 -0
- package/script/pkg/commands/type.js +13 -0
- package/script/pkg/commands/unlink.js +13 -0
- package/script/pkg/commands/zadd.js +30 -0
- package/script/pkg/commands/zcard.js +13 -0
- package/script/pkg/commands/zcount.js +13 -0
- package/script/pkg/commands/zincrby.js +13 -0
- package/script/pkg/commands/zinterstore.js +31 -0
- package/script/pkg/commands/zlexcount.js +13 -0
- package/script/pkg/commands/zpopmax.js +17 -0
- package/script/pkg/commands/zpopmin.js +17 -0
- package/script/pkg/commands/zrange.js +24 -0
- package/script/pkg/commands/zrank.js +13 -0
- package/script/pkg/commands/zrem.js +13 -0
- package/script/pkg/commands/zremrangebylex.js +13 -0
- package/script/pkg/commands/zremrangebyrank.js +13 -0
- package/script/pkg/commands/zremrangebyscore.js +13 -0
- package/script/pkg/commands/zrevrank.js +13 -0
- package/script/pkg/commands/zscan.js +20 -0
- package/script/pkg/commands/zscore.js +13 -0
- package/script/pkg/commands/zunionstore.js +31 -0
- package/script/pkg/error.js +13 -0
- package/script/pkg/http.js +81 -0
- package/script/pkg/pipeline.js +1129 -0
- package/script/pkg/redis.js +1071 -0
- package/script/pkg/types.js +2 -0
- package/script/pkg/util.js +35 -0
- package/script/platforms/cloudflare.js +89 -0
- package/script/platforms/fastly.js +67 -0
- package/script/platforms/node_with_fetch.js +87 -0
- package/script/platforms/nodejs.js +86 -0
- package/types/pkg/commands/append.d.ts +7 -0
- package/types/pkg/commands/bitcount.d.ts +8 -0
- package/types/pkg/commands/bitop.d.ts +13 -0
- package/types/pkg/commands/bitpos.d.ts +7 -0
- package/types/pkg/commands/command.d.ts +37 -0
- package/types/pkg/commands/dbsize.d.ts +7 -0
- package/types/pkg/commands/decr.d.ts +7 -0
- package/types/pkg/commands/decrby.d.ts +7 -0
- package/types/pkg/commands/del.d.ts +7 -0
- package/types/pkg/commands/echo.d.ts +7 -0
- package/types/pkg/commands/eval.d.ts +7 -0
- package/types/pkg/commands/evalsha.d.ts +7 -0
- package/types/pkg/commands/exists.d.ts +7 -0
- package/types/pkg/commands/expire.d.ts +7 -0
- package/types/pkg/commands/expireat.d.ts +7 -0
- package/types/pkg/commands/flushall.d.ts +9 -0
- package/types/pkg/commands/flushdb.d.ts +9 -0
- package/types/pkg/commands/get.d.ts +7 -0
- package/types/pkg/commands/getbit.d.ts +7 -0
- package/types/pkg/commands/getrange.d.ts +7 -0
- package/types/pkg/commands/getset.d.ts +7 -0
- package/types/pkg/commands/hdel.d.ts +7 -0
- package/types/pkg/commands/hexists.d.ts +7 -0
- package/types/pkg/commands/hget.d.ts +7 -0
- package/types/pkg/commands/hgetall.d.ts +7 -0
- package/types/pkg/commands/hincrby.d.ts +7 -0
- package/types/pkg/commands/hincrbyfloat.d.ts +7 -0
- package/types/pkg/commands/hkeys.d.ts +7 -0
- package/types/pkg/commands/hlen.d.ts +7 -0
- package/types/pkg/commands/hmget.d.ts +15 -0
- package/types/pkg/commands/hmset.d.ts +9 -0
- package/types/pkg/commands/hscan.d.ts +24 -0
- package/types/pkg/commands/hset.d.ts +9 -0
- package/types/pkg/commands/hsetnx.d.ts +7 -0
- package/types/pkg/commands/hstrlen.d.ts +7 -0
- package/types/pkg/commands/hvals.d.ts +7 -0
- package/types/pkg/commands/incr.d.ts +7 -0
- package/types/pkg/commands/incrby.d.ts +7 -0
- package/types/pkg/commands/incrbyfloat.d.ts +7 -0
- package/types/pkg/commands/keys.d.ts +7 -0
- package/types/pkg/commands/lindex.d.ts +4 -0
- package/types/pkg/commands/linsert.d.ts +9 -0
- package/types/pkg/commands/llen.d.ts +7 -0
- package/types/pkg/commands/lpop.d.ts +7 -0
- package/types/pkg/commands/lpush.d.ts +7 -0
- package/types/pkg/commands/lpushx.d.ts +7 -0
- package/types/pkg/commands/lrange.d.ts +4 -0
- package/types/pkg/commands/lrem.d.ts +4 -0
- package/types/pkg/commands/lset.d.ts +4 -0
- package/types/pkg/commands/ltrim.d.ts +4 -0
- package/types/pkg/commands/mget.d.ts +7 -0
- package/types/pkg/commands/mod.d.ts +114 -0
- package/types/pkg/commands/mset.d.ts +9 -0
- package/types/pkg/commands/msetnx.d.ts +9 -0
- package/types/pkg/commands/persist.d.ts +7 -0
- package/types/pkg/commands/pexpire.d.ts +7 -0
- package/types/pkg/commands/pexpireat.d.ts +7 -0
- package/types/pkg/commands/ping.d.ts +7 -0
- package/types/pkg/commands/psetex.d.ts +7 -0
- package/types/pkg/commands/pttl.d.ts +7 -0
- package/types/pkg/commands/publish.d.ts +7 -0
- package/types/pkg/commands/randomkey.d.ts +7 -0
- package/types/pkg/commands/rename.d.ts +7 -0
- package/types/pkg/commands/renamenx.d.ts +7 -0
- package/types/pkg/commands/rpop.d.ts +7 -0
- package/types/pkg/commands/rpush.d.ts +7 -0
- package/types/pkg/commands/rpushx.d.ts +7 -0
- package/types/pkg/commands/sadd.d.ts +7 -0
- package/types/pkg/commands/scan.d.ts +17 -0
- package/types/pkg/commands/scard.d.ts +7 -0
- package/types/pkg/commands/script_exists.d.ts +7 -0
- package/types/pkg/commands/script_flush.d.ts +14 -0
- package/types/pkg/commands/script_load.d.ts +7 -0
- package/types/pkg/commands/sdiff.d.ts +7 -0
- package/types/pkg/commands/sdiffstore.d.ts +7 -0
- package/types/pkg/commands/set.d.ts +26 -0
- package/types/pkg/commands/setbit.d.ts +7 -0
- package/types/pkg/commands/setex.d.ts +7 -0
- package/types/pkg/commands/setnx.d.ts +7 -0
- package/types/pkg/commands/setrange.d.ts +7 -0
- package/types/pkg/commands/sinter.d.ts +7 -0
- package/types/pkg/commands/sinterstore.d.ts +7 -0
- package/types/pkg/commands/sismember.d.ts +7 -0
- package/types/pkg/commands/smembers.d.ts +7 -0
- package/types/pkg/commands/smove.d.ts +7 -0
- package/types/pkg/commands/spop.d.ts +7 -0
- package/types/pkg/commands/srandmember.d.ts +7 -0
- package/types/pkg/commands/srem.d.ts +7 -0
- package/types/pkg/commands/sscan.d.ts +24 -0
- package/types/pkg/commands/strlen.d.ts +7 -0
- package/types/pkg/commands/sunion.d.ts +7 -0
- package/types/pkg/commands/sunionstore.d.ts +7 -0
- package/types/pkg/commands/time.d.ts +7 -0
- package/types/pkg/commands/touch.d.ts +7 -0
- package/types/pkg/commands/ttl.d.ts +7 -0
- package/types/pkg/commands/type.d.ts +8 -0
- package/types/pkg/commands/unlink.d.ts +7 -0
- package/types/pkg/commands/zadd.d.ts +35 -0
- package/types/pkg/commands/zcard.d.ts +7 -0
- package/types/pkg/commands/zcount.d.ts +7 -0
- package/types/pkg/commands/zincrby.d.ts +7 -0
- package/types/pkg/commands/zinterstore.d.ts +30 -0
- package/types/pkg/commands/zlexcount.d.ts +7 -0
- package/types/pkg/commands/zpopmax.d.ts +7 -0
- package/types/pkg/commands/zpopmin.d.ts +7 -0
- package/types/pkg/commands/zrange.d.ts +35 -0
- package/types/pkg/commands/zrank.d.ts +7 -0
- package/types/pkg/commands/zrem.d.ts +7 -0
- package/types/pkg/commands/zremrangebylex.d.ts +7 -0
- package/types/pkg/commands/zremrangebyrank.d.ts +7 -0
- package/types/pkg/commands/zremrangebyscore.d.ts +7 -0
- package/types/pkg/commands/zrevrank.d.ts +7 -0
- package/types/pkg/commands/zscan.d.ts +24 -0
- package/types/pkg/commands/zscore.d.ts +7 -0
- package/types/pkg/commands/zunionstore.d.ts +30 -0
- package/types/pkg/error.d.ts +6 -0
- package/types/pkg/http.d.ts +54 -0
- package/types/pkg/pipeline.d.ts +540 -0
- package/types/pkg/redis.d.ts +516 -0
- package/types/pkg/types.d.ts +1 -0
- package/types/pkg/util.d.ts +1 -0
- package/types/platforms/cloudflare.d.ts +42 -0
- package/types/platforms/fastly.d.ts +45 -0
- package/types/platforms/node_with_fetch.d.ts +82 -0
- package/types/platforms/nodejs.d.ts +81 -0
package/.releaserc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Upstash, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# Upstash Redis
|
|
2
|
+
|
|
3
|
+
`@upstash/redis` is an HTTP/REST based Redis client for typescript, built on top
|
|
4
|
+
of [Upstash REST API](https://docs.upstash.com/features/restapi).
|
|
5
|
+
|
|
6
|
+
[](https://github.com/upstash/upstash-redis/actions/workflows/tests.yaml)
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
It is the only connectionless (HTTP based) Redis client and designed for:
|
|
11
|
+
|
|
12
|
+
- Serverless functions (AWS Lambda ...)
|
|
13
|
+
- Cloudflare Workers (see
|
|
14
|
+
[the example](https://github.com/upstash/upstash-redis/tree/master/examples/cloudflare-workers))
|
|
15
|
+
- Fastly Compute@Edge (see
|
|
16
|
+
[the example](https://github.com/upstash/upstash-redis/tree/master/examples/fastly))
|
|
17
|
+
- Next.js, Jamstack ...
|
|
18
|
+
- Client side web/mobile applications
|
|
19
|
+
- WebAssembly
|
|
20
|
+
- and other environments where HTTP is preferred over TCP.
|
|
21
|
+
|
|
22
|
+
See
|
|
23
|
+
[the list of APIs](https://docs.upstash.com/features/restapi#rest---redis-api-compatibility)
|
|
24
|
+
supported.
|
|
25
|
+
|
|
26
|
+
## Upgrading to v1.4.0 **(ReferenceError: fetch is not defined)**
|
|
27
|
+
|
|
28
|
+
If you are running on nodejs v17 and earlier, `fetch` will not be natively
|
|
29
|
+
supported. Platforms like Vercel, Netlify, Deno, Fastly etc. provide a polyfill
|
|
30
|
+
for you. But if you are running on bare node, you need to either specify a
|
|
31
|
+
polyfill yourself or change the import path to:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { Redis } from "@upstash/redis/with-fetch";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Upgrading from v0.2.0?
|
|
38
|
+
|
|
39
|
+
Please read the
|
|
40
|
+
[migration guide](https://github.com/upstash/upstash-redis#migrating-to-v1). For
|
|
41
|
+
further explanation we wrote a
|
|
42
|
+
[blog post](https://blog.upstash.com/upstash-redis-sdk-v1).
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
### Install
|
|
47
|
+
|
|
48
|
+
#### npm
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install @upstash/redis
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Deno
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { Redis } from "https://deno.land/x/upstash_redis/mod.ts";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Create database
|
|
61
|
+
|
|
62
|
+
Create a new redis database on [upstash](https://console.upstash.com/)
|
|
63
|
+
|
|
64
|
+
### Environments
|
|
65
|
+
|
|
66
|
+
We support various platforms, such as nodejs, cloudflare and fastly. Platforms
|
|
67
|
+
differ slightly when it comes to environment variables and their `fetch` api.
|
|
68
|
+
Please use the correct import when deploying to special platforms.
|
|
69
|
+
|
|
70
|
+
#### Node.js
|
|
71
|
+
|
|
72
|
+
Examples: Vercel, Netlify, AWS Lambda
|
|
73
|
+
|
|
74
|
+
If you are running on nodejs you can set `UPSTASH_REDIS_REST_URL` and
|
|
75
|
+
`UPSTASH_REDIS_REST_TOKEN` as environment variable and create a redis instance
|
|
76
|
+
like this:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { Redis } from "@upstash/redis"
|
|
80
|
+
|
|
81
|
+
const redis = new Redis({
|
|
82
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
83
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// or load directly from env
|
|
87
|
+
const redis = Redis.fromEnv()
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If you are running on nodejs v17 and earlier, `fetch` will not be natively
|
|
91
|
+
supported. Platforms like Vercel, Netlify, Deno, Fastly etc. provide a polyfill
|
|
92
|
+
for you. But if you are running on bare node, you need to either specify a
|
|
93
|
+
polyfill yourself or change the import path to:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { Redis } from "@upstash/redis/with-fetch";
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- [Code example](https://github.com/upstash/upstash-redis/blob/main/examples/nodejs)
|
|
100
|
+
|
|
101
|
+
#### Cloudflare Workers
|
|
102
|
+
|
|
103
|
+
Cloudflare handles environment variables differently than nodejs. Please add
|
|
104
|
+
`UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` using
|
|
105
|
+
`wrangler secret put ...` or in the cloudflare dashboard.
|
|
106
|
+
|
|
107
|
+
Afterwards you can create a redis instance:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { Redis } from "@upstash/redis/cloudflare"
|
|
111
|
+
|
|
112
|
+
const redis = new Redis({
|
|
113
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
114
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
// or load directly from global env
|
|
119
|
+
|
|
120
|
+
// service worker
|
|
121
|
+
const redis = Redis.fromEnv()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
// module worker
|
|
125
|
+
export default {
|
|
126
|
+
async fetch(request: Request, env: Bindings) {
|
|
127
|
+
const redis = Redis.fromEnv(env)
|
|
128
|
+
// ...
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- [Code example service worker](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers)
|
|
134
|
+
- [Code example module worker](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers-modules)
|
|
135
|
+
- [Documentation](https://docs.upstash.com/redis/tutorials/cloudflare_workers_with_redis)
|
|
136
|
+
|
|
137
|
+
#### Fastly
|
|
138
|
+
|
|
139
|
+
Fastly introduces a concept called
|
|
140
|
+
[backend](https://developer.fastly.com/reference/api/services/backend/). You
|
|
141
|
+
need to configure a backend in your `fastly.toml`. An example can be found
|
|
142
|
+
[here](https://github.com/upstash/upstash-redis/blob/main/examples/fastly/fastly.toml).
|
|
143
|
+
Until the fastly api stabilizes we recommend creating an instance manually:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { Redis } from "@upstash/redis/fastly"
|
|
147
|
+
|
|
148
|
+
const redis = new Redis({
|
|
149
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
150
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
151
|
+
backend: <BACKEND_NAME>,
|
|
152
|
+
})
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- [Code example](https://github.com/upstash/upstash-redis/tree/main/examples/fastly)
|
|
156
|
+
- [Documentation](https://blog.upstash.com/fastly-compute-edge-with-redi)
|
|
157
|
+
|
|
158
|
+
#### Deno
|
|
159
|
+
|
|
160
|
+
Examples: [Deno Deploy](https://deno.com/deploy),
|
|
161
|
+
[Netlify Edge](https://www.netlify.com/products/edge/)
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import { Redis } from "https://deno.land/x/upstash_redis/mod.ts"
|
|
165
|
+
|
|
166
|
+
const redis = new Redis({
|
|
167
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
168
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
// or
|
|
172
|
+
const redis = Redis.fromEnv();
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Working with types
|
|
176
|
+
|
|
177
|
+
Most commands allow you to provide a type to make working with typescript
|
|
178
|
+
easier.
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
const data = await redis.get<MyCustomType>("key");
|
|
182
|
+
// data is typed as `MyCustomType`
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Migrating to v1
|
|
186
|
+
|
|
187
|
+
### Explicit authentication
|
|
188
|
+
|
|
189
|
+
The library is no longer automatically trying to load connection secrets from
|
|
190
|
+
environment variables. You must either supply them yourself:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import { Redis } from "@upstash/redis"
|
|
194
|
+
|
|
195
|
+
const redis = new Redis({
|
|
196
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
197
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
198
|
+
})
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Or use one of the static constructors to load from environment variables:
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
// Nodejs
|
|
205
|
+
import { Redis } from "@upstash/redis";
|
|
206
|
+
const redis = Redis.fromEnv();
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
// or when deploying to cloudflare workers
|
|
211
|
+
import { Redis } from "@upstash/redis/cloudflare";
|
|
212
|
+
const redis = Redis.fromEnv();
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Error handling
|
|
216
|
+
|
|
217
|
+
Errors are now thrown automatically instead of being returned to you.
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
// old
|
|
221
|
+
const { data, error } = await set("key", "value");
|
|
222
|
+
if (error) {
|
|
223
|
+
throw new Error(error);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// new
|
|
227
|
+
const data = await redis.set("key", "value"); // error is thrown automatically
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Pipeline
|
|
231
|
+
|
|
232
|
+
`v1.0.0` introduces redis pipelines. Pipelining commands allows you to send a
|
|
233
|
+
single http request with multiple commands.
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import { Redis } from "@upstash/redis";
|
|
237
|
+
|
|
238
|
+
const redis = new Redis({
|
|
239
|
+
/* auth */
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
const p = redis.pipeline();
|
|
243
|
+
|
|
244
|
+
// Now you can chain multiple commands to create your pipeline:
|
|
245
|
+
|
|
246
|
+
p.set("key", 2);
|
|
247
|
+
p.incr("key");
|
|
248
|
+
|
|
249
|
+
// or inline:
|
|
250
|
+
p.hset("key2", "field", { hello: "world" }).hvals("key2");
|
|
251
|
+
|
|
252
|
+
// Execute the pipeline once you are done building it:
|
|
253
|
+
// `exec` returns an array where each element represents the response of a command in the pipeline.
|
|
254
|
+
// You can optionally provide a type like this to get a typed response.
|
|
255
|
+
const res = await p.exec<[Type1, Type2, Type3]>();
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
For more information about pipelines using REST see
|
|
259
|
+
[here](https://blog.upstash.com/pipeline).
|
|
260
|
+
|
|
261
|
+
### Advanced
|
|
262
|
+
|
|
263
|
+
A low level `Command` class can be imported from `@upstash/redis` in case you
|
|
264
|
+
need more control about types and or (de)serialization.
|
|
265
|
+
|
|
266
|
+
By default all objects you are storing in redis are serialized using
|
|
267
|
+
`JSON.stringify` and recursively deserialized as well. Here's an example how you
|
|
268
|
+
could customize that behaviour. Keep in mind that you need to provide a `fetch`
|
|
269
|
+
polyfill if you are running on nodejs. We recommend
|
|
270
|
+
[isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch).
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
import { Command } from "@upstash/redis/commands"
|
|
274
|
+
import { HttpClient } from "@upstash/redis/http"
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* TData represents what the user will enter or receive,
|
|
278
|
+
* TResult is the raw data returned from upstash, which may need to be
|
|
279
|
+
* transformed or parsed.
|
|
280
|
+
*/
|
|
281
|
+
const deserialize: (raw: TResult) => TData = ...
|
|
282
|
+
|
|
283
|
+
class CustomGetCommand<TData, TResult> extends Command<TData | null, TResult | null> {
|
|
284
|
+
constructor(key: string, ) {
|
|
285
|
+
super(["get", key], { deserialize })
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const client = new HttpClient({
|
|
290
|
+
baseUrl: <UPSTASH_REDIS_REST_URL>,
|
|
291
|
+
headers: {
|
|
292
|
+
authorization: `Bearer ${<UPSTASH_REDIS_REST_TOKEN>}`,
|
|
293
|
+
},
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
const res = new CustomGetCommand("key").exec(client)
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Additional information
|
|
300
|
+
|
|
301
|
+
#### `keepalive`
|
|
302
|
+
|
|
303
|
+
`@upstash/redis` is capable of reusing connections where possible to minimize
|
|
304
|
+
latency. Connections can be reused if the client is stored in memory and not
|
|
305
|
+
initialized with every new function invocation. The easiest way to achieve this
|
|
306
|
+
is by creating the client outside of your handler and adding an https agent:
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
// Nextjs api route
|
|
310
|
+
import { Redis } from "@upstash/redis";
|
|
311
|
+
import https from "https";
|
|
312
|
+
|
|
313
|
+
const redis = Redis.fromEnv({
|
|
314
|
+
agent: new https.Agent({ keepAlive: true }),
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
export default async function (req, res) {
|
|
318
|
+
// use redis here
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Whenever your hot lambda receives a new request the client is already
|
|
323
|
+
initialized and the previously established connection to upstash is reused.
|
|
324
|
+
|
|
325
|
+
#### Javascript MAX_SAFE_INTEGER
|
|
326
|
+
|
|
327
|
+
Javascript can not handle numbers larger than `2^53 -1` safely and would return
|
|
328
|
+
wrong results when trying to deserialize them. In these cases the default
|
|
329
|
+
deserializer will return them as string instead. This might cause a mismatch
|
|
330
|
+
with your custom types.
|
|
331
|
+
|
|
332
|
+
```ts
|
|
333
|
+
await redis.set("key", "101600000000150081467");
|
|
334
|
+
const res = await redis<number>("get");
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
In this example `res` will still be a string despite the type annotation. Please
|
|
338
|
+
keep that in mind and adjust accordingly.
|
|
339
|
+
|
|
340
|
+
## Docs
|
|
341
|
+
|
|
342
|
+
See [the documentation](https://docs.upstash.com/features/javascriptsdk) for
|
|
343
|
+
details.
|
|
344
|
+
|
|
345
|
+
## Contributing
|
|
346
|
+
|
|
347
|
+
### [Install Deno](https://deno.land/#installation)
|
|
348
|
+
|
|
349
|
+
### Database
|
|
350
|
+
|
|
351
|
+
Create a new redis database on [upstash](https://console.upstash.com/) and copy
|
|
352
|
+
the url and token
|
|
353
|
+
|
|
354
|
+
### Running tests
|
|
355
|
+
|
|
356
|
+
```sh
|
|
357
|
+
UPSTASH_REDIS_REST_URL=".." UPSTASH_REDIS_REST_TOKEN=".." deno test -A
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
```
|
|
361
|
+
```
|
package/esm/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/bitcount
|
|
4
|
+
*/
|
|
5
|
+
export class BitCountCommand extends Command {
|
|
6
|
+
constructor([key, start, end], opts) {
|
|
7
|
+
const command = ["bitcount", key];
|
|
8
|
+
if (typeof start === "number") {
|
|
9
|
+
command.push(start);
|
|
10
|
+
}
|
|
11
|
+
if (typeof end === "number") {
|
|
12
|
+
command.push(end);
|
|
13
|
+
}
|
|
14
|
+
super(command, opts);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { UpstashError } from "../error.js";
|
|
2
|
+
import { parseResponse } from "../util.js";
|
|
3
|
+
const defaultSerializer = (c) => typeof c === "string" ? c : JSON.stringify(c);
|
|
4
|
+
/**
|
|
5
|
+
* Command offers default (de)serialization and the exec method to all commands.
|
|
6
|
+
*
|
|
7
|
+
* TData represents what the user will enter or receive,
|
|
8
|
+
* TResult is the raw data returned from upstash, which may need to be transformed or parsed.
|
|
9
|
+
*/
|
|
10
|
+
export class Command {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new command instance.
|
|
13
|
+
*
|
|
14
|
+
* You can define a custom `deserialize` function. By default we try to deserialize as json.
|
|
15
|
+
*/
|
|
16
|
+
constructor(command, opts) {
|
|
17
|
+
Object.defineProperty(this, "command", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "serialize", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "deserialize", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
35
|
+
this.serialize = defaultSerializer;
|
|
36
|
+
this.deserialize = typeof opts?.automaticDeserialization === "undefined" ||
|
|
37
|
+
opts.automaticDeserialization
|
|
38
|
+
? opts?.deserialize ?? parseResponse
|
|
39
|
+
: (x) => x;
|
|
40
|
+
this.command = command.map(this.serialize);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Execute the command using a client.
|
|
44
|
+
*/
|
|
45
|
+
async exec(client) {
|
|
46
|
+
const { result, error } = await client.request({
|
|
47
|
+
body: this.command,
|
|
48
|
+
});
|
|
49
|
+
if (error) {
|
|
50
|
+
throw new UpstashError(error);
|
|
51
|
+
}
|
|
52
|
+
if (typeof result === "undefined") {
|
|
53
|
+
throw new Error(`Request did not return a result`);
|
|
54
|
+
}
|
|
55
|
+
return this.deserialize(result);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/flushall
|
|
4
|
+
*/
|
|
5
|
+
export class FlushAllCommand extends Command {
|
|
6
|
+
constructor(args, opts) {
|
|
7
|
+
const command = ["flushall"];
|
|
8
|
+
if (args && args.length > 0 && args[0].async) {
|
|
9
|
+
command.push("async");
|
|
10
|
+
}
|
|
11
|
+
super(command, opts);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/flushdb
|
|
4
|
+
*/
|
|
5
|
+
export class FlushDBCommand extends Command {
|
|
6
|
+
constructor([opts], cmdOpts) {
|
|
7
|
+
const command = ["flushdb"];
|
|
8
|
+
if (opts?.async) {
|
|
9
|
+
command.push("async");
|
|
10
|
+
}
|
|
11
|
+
super(command, cmdOpts);
|
|
12
|
+
}
|
|
13
|
+
}
|