@upstash/redis 0.0.0-ci.8ae20814 → 0.0.0-ci.8bd938831856fbab2f4aadc67ecb9de61efb6123
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/.npmrc +1 -0
- package/README.md +43 -280
- package/cloudflare.d.mts +45 -0
- package/{types/platforms/cloudflare.d.ts → cloudflare.d.ts} +14 -11
- package/cloudflare.js +3062 -0
- package/cloudflare.js.map +1 -0
- package/cloudflare.mjs +3025 -0
- package/cloudflare.mjs.map +1 -0
- package/fastly.d.mts +43 -0
- package/{types/platforms/fastly.d.ts → fastly.d.ts} +8 -10
- package/fastly.js +3037 -0
- package/fastly.js.map +1 -0
- package/fastly.mjs +3000 -0
- package/fastly.mjs.map +1 -0
- package/{types/platforms/node_with_fetch.d.ts → nodejs.d.mts} +9 -11
- package/{types/platforms/nodejs.d.ts → nodejs.d.ts} +9 -10
- package/nodejs.js +3063 -0
- package/nodejs.js.map +1 -0
- package/nodejs.mjs +3026 -0
- package/nodejs.mjs.map +1 -0
- package/package.json +29 -76
- package/redis-e3e8473f.d.ts +1795 -0
- package/.releaserc +0 -14
- package/esm/package.json +0 -3
- package/esm/pkg/commands/append.js +0 -9
- package/esm/pkg/commands/bitcount.js +0 -16
- package/esm/pkg/commands/bitop.js +0 -9
- package/esm/pkg/commands/bitpos.js +0 -9
- package/esm/pkg/commands/command.js +0 -57
- package/esm/pkg/commands/dbsize.js +0 -9
- package/esm/pkg/commands/decr.js +0 -9
- package/esm/pkg/commands/decrby.js +0 -9
- package/esm/pkg/commands/del.js +0 -9
- package/esm/pkg/commands/echo.js +0 -9
- package/esm/pkg/commands/eval.js +0 -9
- package/esm/pkg/commands/evalsha.js +0 -9
- package/esm/pkg/commands/exists.js +0 -9
- package/esm/pkg/commands/expire.js +0 -9
- package/esm/pkg/commands/expireat.js +0 -9
- package/esm/pkg/commands/flushall.js +0 -13
- package/esm/pkg/commands/flushdb.js +0 -13
- package/esm/pkg/commands/get.js +0 -9
- package/esm/pkg/commands/getbit.js +0 -9
- package/esm/pkg/commands/getrange.js +0 -9
- package/esm/pkg/commands/getset.js +0 -9
- package/esm/pkg/commands/hdel.js +0 -9
- package/esm/pkg/commands/hexists.js +0 -9
- package/esm/pkg/commands/hget.js +0 -9
- package/esm/pkg/commands/hgetall.js +0 -33
- package/esm/pkg/commands/hincrby.js +0 -9
- package/esm/pkg/commands/hincrbyfloat.js +0 -9
- package/esm/pkg/commands/hkeys.js +0 -9
- package/esm/pkg/commands/hlen.js +0 -9
- package/esm/pkg/commands/hmget.js +0 -35
- package/esm/pkg/commands/hmset.js +0 -13
- package/esm/pkg/commands/hscan.js +0 -16
- package/esm/pkg/commands/hset.js +0 -13
- package/esm/pkg/commands/hsetnx.js +0 -9
- package/esm/pkg/commands/hstrlen.js +0 -9
- package/esm/pkg/commands/hvals.js +0 -9
- package/esm/pkg/commands/incr.js +0 -9
- package/esm/pkg/commands/incrby.js +0 -9
- package/esm/pkg/commands/incrbyfloat.js +0 -9
- package/esm/pkg/commands/keys.js +0 -9
- package/esm/pkg/commands/lindex.js +0 -6
- package/esm/pkg/commands/linsert.js +0 -6
- package/esm/pkg/commands/llen.js +0 -9
- package/esm/pkg/commands/lpop.js +0 -9
- package/esm/pkg/commands/lpush.js +0 -9
- package/esm/pkg/commands/lpushx.js +0 -9
- package/esm/pkg/commands/lrange.js +0 -6
- package/esm/pkg/commands/lrem.js +0 -6
- package/esm/pkg/commands/lset.js +0 -6
- package/esm/pkg/commands/ltrim.js +0 -6
- package/esm/pkg/commands/mget.js +0 -9
- package/esm/pkg/commands/mod.js +0 -114
- package/esm/pkg/commands/mset.js +0 -12
- package/esm/pkg/commands/msetnx.js +0 -9
- package/esm/pkg/commands/persist.js +0 -9
- package/esm/pkg/commands/pexpire.js +0 -9
- package/esm/pkg/commands/pexpireat.js +0 -9
- package/esm/pkg/commands/ping.js +0 -13
- package/esm/pkg/commands/psetex.js +0 -9
- package/esm/pkg/commands/pttl.js +0 -9
- package/esm/pkg/commands/publish.js +0 -9
- package/esm/pkg/commands/randomkey.js +0 -9
- package/esm/pkg/commands/rename.js +0 -9
- package/esm/pkg/commands/renamenx.js +0 -9
- package/esm/pkg/commands/rpop.js +0 -9
- package/esm/pkg/commands/rpush.js +0 -9
- package/esm/pkg/commands/rpushx.js +0 -9
- package/esm/pkg/commands/sadd.js +0 -9
- package/esm/pkg/commands/scan.js +0 -16
- package/esm/pkg/commands/scard.js +0 -9
- package/esm/pkg/commands/script_exists.js +0 -12
- package/esm/pkg/commands/script_flush.js +0 -16
- package/esm/pkg/commands/script_load.js +0 -9
- package/esm/pkg/commands/sdiff.js +0 -9
- package/esm/pkg/commands/sdiffstore.js +0 -9
- package/esm/pkg/commands/set.js +0 -24
- package/esm/pkg/commands/setbit.js +0 -9
- package/esm/pkg/commands/setex.js +0 -9
- package/esm/pkg/commands/setnx.js +0 -9
- package/esm/pkg/commands/setrange.js +0 -9
- package/esm/pkg/commands/sinter.js +0 -9
- package/esm/pkg/commands/sinterstore.js +0 -9
- package/esm/pkg/commands/sismember.js +0 -9
- package/esm/pkg/commands/smembers.js +0 -9
- package/esm/pkg/commands/smove.js +0 -9
- package/esm/pkg/commands/spop.js +0 -13
- package/esm/pkg/commands/srandmember.js +0 -13
- package/esm/pkg/commands/srem.js +0 -9
- package/esm/pkg/commands/sscan.js +0 -16
- package/esm/pkg/commands/strlen.js +0 -9
- package/esm/pkg/commands/sunion.js +0 -9
- package/esm/pkg/commands/sunionstore.js +0 -9
- package/esm/pkg/commands/time.js +0 -9
- package/esm/pkg/commands/touch.js +0 -9
- package/esm/pkg/commands/ttl.js +0 -9
- package/esm/pkg/commands/type.js +0 -9
- package/esm/pkg/commands/unlink.js +0 -9
- package/esm/pkg/commands/zadd.js +0 -26
- package/esm/pkg/commands/zcard.js +0 -9
- package/esm/pkg/commands/zcount.js +0 -9
- package/esm/pkg/commands/zincrby.js +0 -9
- package/esm/pkg/commands/zinterstore.js +0 -27
- package/esm/pkg/commands/zlexcount.js +0 -9
- package/esm/pkg/commands/zpopmax.js +0 -13
- package/esm/pkg/commands/zpopmin.js +0 -13
- package/esm/pkg/commands/zrange.js +0 -20
- package/esm/pkg/commands/zrank.js +0 -9
- package/esm/pkg/commands/zrem.js +0 -9
- package/esm/pkg/commands/zremrangebylex.js +0 -9
- package/esm/pkg/commands/zremrangebyrank.js +0 -9
- package/esm/pkg/commands/zremrangebyscore.js +0 -9
- package/esm/pkg/commands/zrevrank.js +0 -9
- package/esm/pkg/commands/zscan.js +0 -16
- package/esm/pkg/commands/zscore.js +0 -9
- package/esm/pkg/commands/zunionstore.js +0 -27
- package/esm/pkg/error.js +0 -9
- package/esm/pkg/http.js +0 -77
- package/esm/pkg/pipeline.js +0 -1125
- package/esm/pkg/redis.js +0 -1067
- package/esm/pkg/types.js +0 -1
- package/esm/pkg/util.js +0 -31
- package/esm/platforms/cloudflare.js +0 -62
- package/esm/platforms/fastly.js +0 -40
- package/esm/platforms/node_with_fetch.js +0 -60
- package/esm/platforms/nodejs.js +0 -59
- package/script/package.json +0 -3
- package/script/pkg/commands/append.js +0 -13
- package/script/pkg/commands/bitcount.js +0 -20
- package/script/pkg/commands/bitop.js +0 -13
- package/script/pkg/commands/bitpos.js +0 -13
- package/script/pkg/commands/command.js +0 -61
- package/script/pkg/commands/dbsize.js +0 -13
- package/script/pkg/commands/decr.js +0 -13
- package/script/pkg/commands/decrby.js +0 -13
- package/script/pkg/commands/del.js +0 -13
- package/script/pkg/commands/echo.js +0 -13
- package/script/pkg/commands/eval.js +0 -13
- package/script/pkg/commands/evalsha.js +0 -13
- package/script/pkg/commands/exists.js +0 -13
- package/script/pkg/commands/expire.js +0 -13
- package/script/pkg/commands/expireat.js +0 -13
- package/script/pkg/commands/flushall.js +0 -17
- package/script/pkg/commands/flushdb.js +0 -17
- package/script/pkg/commands/get.js +0 -13
- package/script/pkg/commands/getbit.js +0 -13
- package/script/pkg/commands/getrange.js +0 -13
- package/script/pkg/commands/getset.js +0 -13
- package/script/pkg/commands/hdel.js +0 -13
- package/script/pkg/commands/hexists.js +0 -13
- package/script/pkg/commands/hget.js +0 -13
- package/script/pkg/commands/hgetall.js +0 -37
- package/script/pkg/commands/hincrby.js +0 -13
- package/script/pkg/commands/hincrbyfloat.js +0 -13
- package/script/pkg/commands/hkeys.js +0 -13
- package/script/pkg/commands/hlen.js +0 -13
- package/script/pkg/commands/hmget.js +0 -39
- package/script/pkg/commands/hmset.js +0 -17
- package/script/pkg/commands/hscan.js +0 -20
- package/script/pkg/commands/hset.js +0 -17
- package/script/pkg/commands/hsetnx.js +0 -13
- package/script/pkg/commands/hstrlen.js +0 -13
- package/script/pkg/commands/hvals.js +0 -13
- package/script/pkg/commands/incr.js +0 -13
- package/script/pkg/commands/incrby.js +0 -13
- package/script/pkg/commands/incrbyfloat.js +0 -13
- package/script/pkg/commands/keys.js +0 -13
- package/script/pkg/commands/lindex.js +0 -10
- package/script/pkg/commands/linsert.js +0 -10
- package/script/pkg/commands/llen.js +0 -13
- package/script/pkg/commands/lpop.js +0 -13
- package/script/pkg/commands/lpush.js +0 -13
- package/script/pkg/commands/lpushx.js +0 -13
- package/script/pkg/commands/lrange.js +0 -10
- package/script/pkg/commands/lrem.js +0 -10
- package/script/pkg/commands/lset.js +0 -10
- package/script/pkg/commands/ltrim.js +0 -10
- package/script/pkg/commands/mget.js +0 -13
- package/script/pkg/commands/mod.js +0 -130
- package/script/pkg/commands/mset.js +0 -16
- package/script/pkg/commands/msetnx.js +0 -13
- package/script/pkg/commands/persist.js +0 -13
- package/script/pkg/commands/pexpire.js +0 -13
- package/script/pkg/commands/pexpireat.js +0 -13
- package/script/pkg/commands/ping.js +0 -17
- package/script/pkg/commands/psetex.js +0 -13
- package/script/pkg/commands/pttl.js +0 -13
- package/script/pkg/commands/publish.js +0 -13
- package/script/pkg/commands/randomkey.js +0 -13
- package/script/pkg/commands/rename.js +0 -13
- package/script/pkg/commands/renamenx.js +0 -13
- package/script/pkg/commands/rpop.js +0 -13
- package/script/pkg/commands/rpush.js +0 -13
- package/script/pkg/commands/rpushx.js +0 -13
- package/script/pkg/commands/sadd.js +0 -13
- package/script/pkg/commands/scan.js +0 -20
- package/script/pkg/commands/scard.js +0 -13
- package/script/pkg/commands/script_exists.js +0 -16
- package/script/pkg/commands/script_flush.js +0 -20
- package/script/pkg/commands/script_load.js +0 -13
- package/script/pkg/commands/sdiff.js +0 -13
- package/script/pkg/commands/sdiffstore.js +0 -13
- package/script/pkg/commands/set.js +0 -28
- package/script/pkg/commands/setbit.js +0 -13
- package/script/pkg/commands/setex.js +0 -13
- package/script/pkg/commands/setnx.js +0 -13
- package/script/pkg/commands/setrange.js +0 -13
- package/script/pkg/commands/sinter.js +0 -13
- package/script/pkg/commands/sinterstore.js +0 -13
- package/script/pkg/commands/sismember.js +0 -13
- package/script/pkg/commands/smembers.js +0 -13
- package/script/pkg/commands/smove.js +0 -13
- package/script/pkg/commands/spop.js +0 -17
- package/script/pkg/commands/srandmember.js +0 -17
- package/script/pkg/commands/srem.js +0 -13
- package/script/pkg/commands/sscan.js +0 -20
- package/script/pkg/commands/strlen.js +0 -13
- package/script/pkg/commands/sunion.js +0 -13
- package/script/pkg/commands/sunionstore.js +0 -13
- package/script/pkg/commands/time.js +0 -13
- package/script/pkg/commands/touch.js +0 -13
- package/script/pkg/commands/ttl.js +0 -13
- package/script/pkg/commands/type.js +0 -13
- package/script/pkg/commands/unlink.js +0 -13
- package/script/pkg/commands/zadd.js +0 -30
- package/script/pkg/commands/zcard.js +0 -13
- package/script/pkg/commands/zcount.js +0 -13
- package/script/pkg/commands/zincrby.js +0 -13
- package/script/pkg/commands/zinterstore.js +0 -31
- package/script/pkg/commands/zlexcount.js +0 -13
- package/script/pkg/commands/zpopmax.js +0 -17
- package/script/pkg/commands/zpopmin.js +0 -17
- package/script/pkg/commands/zrange.js +0 -24
- package/script/pkg/commands/zrank.js +0 -13
- package/script/pkg/commands/zrem.js +0 -13
- package/script/pkg/commands/zremrangebylex.js +0 -13
- package/script/pkg/commands/zremrangebyrank.js +0 -13
- package/script/pkg/commands/zremrangebyscore.js +0 -13
- package/script/pkg/commands/zrevrank.js +0 -13
- package/script/pkg/commands/zscan.js +0 -20
- package/script/pkg/commands/zscore.js +0 -13
- package/script/pkg/commands/zunionstore.js +0 -31
- package/script/pkg/error.js +0 -13
- package/script/pkg/http.js +0 -81
- package/script/pkg/pipeline.js +0 -1129
- package/script/pkg/redis.js +0 -1071
- package/script/pkg/types.js +0 -2
- package/script/pkg/util.js +0 -35
- package/script/platforms/cloudflare.js +0 -89
- package/script/platforms/fastly.js +0 -67
- package/script/platforms/node_with_fetch.js +0 -87
- package/script/platforms/nodejs.js +0 -86
- package/types/pkg/commands/append.d.ts +0 -7
- package/types/pkg/commands/bitcount.d.ts +0 -8
- package/types/pkg/commands/bitop.d.ts +0 -13
- package/types/pkg/commands/bitpos.d.ts +0 -7
- package/types/pkg/commands/command.d.ts +0 -37
- package/types/pkg/commands/dbsize.d.ts +0 -7
- package/types/pkg/commands/decr.d.ts +0 -7
- package/types/pkg/commands/decrby.d.ts +0 -7
- package/types/pkg/commands/del.d.ts +0 -7
- package/types/pkg/commands/echo.d.ts +0 -7
- package/types/pkg/commands/eval.d.ts +0 -7
- package/types/pkg/commands/evalsha.d.ts +0 -7
- package/types/pkg/commands/exists.d.ts +0 -7
- package/types/pkg/commands/expire.d.ts +0 -7
- package/types/pkg/commands/expireat.d.ts +0 -7
- package/types/pkg/commands/flushall.d.ts +0 -9
- package/types/pkg/commands/flushdb.d.ts +0 -9
- package/types/pkg/commands/get.d.ts +0 -7
- package/types/pkg/commands/getbit.d.ts +0 -7
- package/types/pkg/commands/getrange.d.ts +0 -7
- package/types/pkg/commands/getset.d.ts +0 -7
- package/types/pkg/commands/hdel.d.ts +0 -7
- package/types/pkg/commands/hexists.d.ts +0 -7
- package/types/pkg/commands/hget.d.ts +0 -7
- package/types/pkg/commands/hgetall.d.ts +0 -7
- package/types/pkg/commands/hincrby.d.ts +0 -7
- package/types/pkg/commands/hincrbyfloat.d.ts +0 -7
- package/types/pkg/commands/hkeys.d.ts +0 -7
- package/types/pkg/commands/hlen.d.ts +0 -7
- package/types/pkg/commands/hmget.d.ts +0 -15
- package/types/pkg/commands/hmset.d.ts +0 -9
- package/types/pkg/commands/hscan.d.ts +0 -24
- package/types/pkg/commands/hset.d.ts +0 -9
- package/types/pkg/commands/hsetnx.d.ts +0 -7
- package/types/pkg/commands/hstrlen.d.ts +0 -7
- package/types/pkg/commands/hvals.d.ts +0 -7
- package/types/pkg/commands/incr.d.ts +0 -7
- package/types/pkg/commands/incrby.d.ts +0 -7
- package/types/pkg/commands/incrbyfloat.d.ts +0 -7
- package/types/pkg/commands/keys.d.ts +0 -7
- package/types/pkg/commands/lindex.d.ts +0 -4
- package/types/pkg/commands/linsert.d.ts +0 -9
- package/types/pkg/commands/llen.d.ts +0 -7
- package/types/pkg/commands/lpop.d.ts +0 -7
- package/types/pkg/commands/lpush.d.ts +0 -7
- package/types/pkg/commands/lpushx.d.ts +0 -7
- package/types/pkg/commands/lrange.d.ts +0 -4
- package/types/pkg/commands/lrem.d.ts +0 -4
- package/types/pkg/commands/lset.d.ts +0 -4
- package/types/pkg/commands/ltrim.d.ts +0 -4
- package/types/pkg/commands/mget.d.ts +0 -7
- package/types/pkg/commands/mod.d.ts +0 -114
- package/types/pkg/commands/mset.d.ts +0 -9
- package/types/pkg/commands/msetnx.d.ts +0 -9
- package/types/pkg/commands/persist.d.ts +0 -7
- package/types/pkg/commands/pexpire.d.ts +0 -7
- package/types/pkg/commands/pexpireat.d.ts +0 -7
- package/types/pkg/commands/ping.d.ts +0 -7
- package/types/pkg/commands/psetex.d.ts +0 -7
- package/types/pkg/commands/pttl.d.ts +0 -7
- package/types/pkg/commands/publish.d.ts +0 -7
- package/types/pkg/commands/randomkey.d.ts +0 -7
- package/types/pkg/commands/rename.d.ts +0 -7
- package/types/pkg/commands/renamenx.d.ts +0 -7
- package/types/pkg/commands/rpop.d.ts +0 -7
- package/types/pkg/commands/rpush.d.ts +0 -7
- package/types/pkg/commands/rpushx.d.ts +0 -7
- package/types/pkg/commands/sadd.d.ts +0 -7
- package/types/pkg/commands/scan.d.ts +0 -17
- package/types/pkg/commands/scard.d.ts +0 -7
- package/types/pkg/commands/script_exists.d.ts +0 -7
- package/types/pkg/commands/script_flush.d.ts +0 -14
- package/types/pkg/commands/script_load.d.ts +0 -7
- package/types/pkg/commands/sdiff.d.ts +0 -7
- package/types/pkg/commands/sdiffstore.d.ts +0 -7
- package/types/pkg/commands/set.d.ts +0 -26
- package/types/pkg/commands/setbit.d.ts +0 -7
- package/types/pkg/commands/setex.d.ts +0 -7
- package/types/pkg/commands/setnx.d.ts +0 -7
- package/types/pkg/commands/setrange.d.ts +0 -7
- package/types/pkg/commands/sinter.d.ts +0 -7
- package/types/pkg/commands/sinterstore.d.ts +0 -7
- package/types/pkg/commands/sismember.d.ts +0 -7
- package/types/pkg/commands/smembers.d.ts +0 -7
- package/types/pkg/commands/smove.d.ts +0 -7
- package/types/pkg/commands/spop.d.ts +0 -7
- package/types/pkg/commands/srandmember.d.ts +0 -7
- package/types/pkg/commands/srem.d.ts +0 -7
- package/types/pkg/commands/sscan.d.ts +0 -24
- package/types/pkg/commands/strlen.d.ts +0 -7
- package/types/pkg/commands/sunion.d.ts +0 -7
- package/types/pkg/commands/sunionstore.d.ts +0 -7
- package/types/pkg/commands/time.d.ts +0 -7
- package/types/pkg/commands/touch.d.ts +0 -7
- package/types/pkg/commands/ttl.d.ts +0 -7
- package/types/pkg/commands/type.d.ts +0 -8
- package/types/pkg/commands/unlink.d.ts +0 -7
- package/types/pkg/commands/zadd.d.ts +0 -35
- package/types/pkg/commands/zcard.d.ts +0 -7
- package/types/pkg/commands/zcount.d.ts +0 -7
- package/types/pkg/commands/zincrby.d.ts +0 -7
- package/types/pkg/commands/zinterstore.d.ts +0 -30
- package/types/pkg/commands/zlexcount.d.ts +0 -7
- package/types/pkg/commands/zpopmax.d.ts +0 -7
- package/types/pkg/commands/zpopmin.d.ts +0 -7
- package/types/pkg/commands/zrange.d.ts +0 -35
- package/types/pkg/commands/zrank.d.ts +0 -7
- package/types/pkg/commands/zrem.d.ts +0 -7
- package/types/pkg/commands/zremrangebylex.d.ts +0 -7
- package/types/pkg/commands/zremrangebyrank.d.ts +0 -7
- package/types/pkg/commands/zremrangebyscore.d.ts +0 -7
- package/types/pkg/commands/zrevrank.d.ts +0 -7
- package/types/pkg/commands/zscan.d.ts +0 -24
- package/types/pkg/commands/zscore.d.ts +0 -7
- package/types/pkg/commands/zunionstore.d.ts +0 -30
- package/types/pkg/error.d.ts +0 -6
- package/types/pkg/http.d.ts +0 -54
- package/types/pkg/pipeline.d.ts +0 -540
- package/types/pkg/redis.d.ts +0 -516
- package/types/pkg/types.d.ts +0 -1
- package/types/pkg/util.d.ts +0 -1
package/.npmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//registry.npmjs.org/:_authToken=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
|
package/README.md
CHANGED
|
@@ -23,29 +23,11 @@ See
|
|
|
23
23
|
[the list of APIs](https://docs.upstash.com/features/restapi#rest---redis-api-compatibility)
|
|
24
24
|
supported.
|
|
25
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
26
|
## Quick Start
|
|
45
27
|
|
|
46
28
|
### Install
|
|
47
29
|
|
|
48
|
-
####
|
|
30
|
+
#### Node.js
|
|
49
31
|
|
|
50
32
|
```bash
|
|
51
33
|
npm install @upstash/redis
|
|
@@ -54,141 +36,14 @@ npm install @upstash/redis
|
|
|
54
36
|
#### Deno
|
|
55
37
|
|
|
56
38
|
```ts
|
|
57
|
-
import { Redis } from "https://deno.land/x/upstash_redis/mod
|
|
39
|
+
import { Redis } from "https://deno.land/x/upstash_redis/mod";
|
|
58
40
|
```
|
|
59
41
|
|
|
60
42
|
### Create database
|
|
61
43
|
|
|
62
44
|
Create a new redis database on [upstash](https://console.upstash.com/)
|
|
63
45
|
|
|
64
|
-
|
|
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](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers)
|
|
134
|
-
- [Code example typescript](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers-with-typescript)
|
|
135
|
-
- [Code example Wrangler 1](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers-with-wrangler-1)
|
|
136
|
-
- [Documentation](https://docs.upstash.com/redis/tutorials/cloudflare_workers_with_redis)
|
|
137
|
-
|
|
138
|
-
#### Fastly
|
|
139
|
-
|
|
140
|
-
Fastly introduces a concept called
|
|
141
|
-
[backend](https://developer.fastly.com/reference/api/services/backend/). You
|
|
142
|
-
need to configure a backend in your `fastly.toml`. An example can be found
|
|
143
|
-
[here](https://github.com/upstash/upstash-redis/blob/main/examples/fastly/fastly.toml).
|
|
144
|
-
Until the fastly api stabilizes we recommend creating an instance manually:
|
|
145
|
-
|
|
146
|
-
```ts
|
|
147
|
-
import { Redis } from "@upstash/redis/fastly"
|
|
148
|
-
|
|
149
|
-
const redis = new Redis({
|
|
150
|
-
url: <UPSTASH_REDIS_REST_URL>,
|
|
151
|
-
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
152
|
-
backend: <BACKEND_NAME>,
|
|
153
|
-
})
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
- [Code example](https://github.com/upstash/upstash-redis/tree/main/examples/fastly)
|
|
157
|
-
- [Documentation](https://blog.upstash.com/fastly-compute-edge-with-redi)
|
|
158
|
-
|
|
159
|
-
#### Deno
|
|
160
|
-
|
|
161
|
-
Examples: [Deno Deploy](https://deno.com/deploy),
|
|
162
|
-
[Netlify Edge](https://www.netlify.com/products/edge/)
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
import { Redis } from "https://deno.land/x/upstash_redis/mod.ts"
|
|
166
|
-
|
|
167
|
-
const redis = new Redis({
|
|
168
|
-
url: <UPSTASH_REDIS_REST_URL>,
|
|
169
|
-
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
// or
|
|
173
|
-
const redis = Redis.fromEnv();
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Working with types
|
|
177
|
-
|
|
178
|
-
Most commands allow you to provide a type to make working with typescript
|
|
179
|
-
easier.
|
|
180
|
-
|
|
181
|
-
```ts
|
|
182
|
-
const data = await redis.get<MyCustomType>("key");
|
|
183
|
-
// data is typed as `MyCustomType`
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
## Migrating to v1
|
|
187
|
-
|
|
188
|
-
### Explicit authentication
|
|
189
|
-
|
|
190
|
-
The library is no longer automatically trying to load connection secrets from
|
|
191
|
-
environment variables. You must either supply them yourself:
|
|
46
|
+
## Basic Usage:
|
|
192
47
|
|
|
193
48
|
```ts
|
|
194
49
|
import { Redis } from "@upstash/redis"
|
|
@@ -197,146 +52,41 @@ const redis = new Redis({
|
|
|
197
52
|
url: <UPSTASH_REDIS_REST_URL>,
|
|
198
53
|
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
199
54
|
})
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
Or use one of the static constructors to load from environment variables:
|
|
203
|
-
|
|
204
|
-
```ts
|
|
205
|
-
// Nodejs
|
|
206
|
-
import { Redis } from "@upstash/redis";
|
|
207
|
-
const redis = Redis.fromEnv();
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
```ts
|
|
211
|
-
// or when deploying to cloudflare workers
|
|
212
|
-
import { Redis } from "@upstash/redis/cloudflare";
|
|
213
|
-
const redis = Redis.fromEnv();
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Error handling
|
|
217
|
-
|
|
218
|
-
Errors are now thrown automatically instead of being returned to you.
|
|
219
|
-
|
|
220
|
-
```ts
|
|
221
|
-
// old
|
|
222
|
-
const { data, error } = await set("key", "value");
|
|
223
|
-
if (error) {
|
|
224
|
-
throw new Error(error);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// new
|
|
228
|
-
const data = await redis.set("key", "value"); // error is thrown automatically
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Pipeline
|
|
232
|
-
|
|
233
|
-
`v1.0.0` introduces redis pipelines. Pipelining commands allows you to send a
|
|
234
|
-
single http request with multiple commands.
|
|
235
|
-
|
|
236
|
-
```ts
|
|
237
|
-
import { Redis } from "@upstash/redis";
|
|
238
|
-
|
|
239
|
-
const redis = new Redis({
|
|
240
|
-
/* auth */
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
const p = redis.pipeline();
|
|
244
|
-
|
|
245
|
-
// Now you can chain multiple commands to create your pipeline:
|
|
246
|
-
|
|
247
|
-
p.set("key", 2);
|
|
248
|
-
p.incr("key");
|
|
249
|
-
|
|
250
|
-
// or inline:
|
|
251
|
-
p.hset("key2", "field", { hello: "world" }).hvals("key2");
|
|
252
|
-
|
|
253
|
-
// Execute the pipeline once you are done building it:
|
|
254
|
-
// `exec` returns an array where each element represents the response of a command in the pipeline.
|
|
255
|
-
// You can optionally provide a type like this to get a typed response.
|
|
256
|
-
const res = await p.exec<[Type1, Type2, Type3]>();
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
For more information about pipelines using REST see
|
|
260
|
-
[here](https://blog.upstash.com/pipeline).
|
|
261
|
-
|
|
262
|
-
### Advanced
|
|
263
|
-
|
|
264
|
-
A low level `Command` class can be imported from `@upstash/redis` in case you
|
|
265
|
-
need more control about types and or (de)serialization.
|
|
266
|
-
|
|
267
|
-
By default all objects you are storing in redis are serialized using
|
|
268
|
-
`JSON.stringify` and recursively deserialized as well. Here's an example how you
|
|
269
|
-
could customize that behaviour. Keep in mind that you need to provide a `fetch`
|
|
270
|
-
polyfill if you are running on nodejs. We recommend
|
|
271
|
-
[isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch).
|
|
272
|
-
|
|
273
|
-
```ts
|
|
274
|
-
import { Command } from "@upstash/redis/commands"
|
|
275
|
-
import { HttpClient } from "@upstash/redis/http"
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* TData represents what the user will enter or receive,
|
|
279
|
-
* TResult is the raw data returned from upstash, which may need to be
|
|
280
|
-
* transformed or parsed.
|
|
281
|
-
*/
|
|
282
|
-
const deserialize: (raw: TResult) => TData = ...
|
|
283
|
-
|
|
284
|
-
class CustomGetCommand<TData, TResult> extends Command<TData | null, TResult | null> {
|
|
285
|
-
constructor(key: string, ) {
|
|
286
|
-
super(["get", key], { deserialize })
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const client = new HttpClient({
|
|
291
|
-
baseUrl: <UPSTASH_REDIS_REST_URL>,
|
|
292
|
-
headers: {
|
|
293
|
-
authorization: `Bearer ${<UPSTASH_REDIS_REST_TOKEN>}`,
|
|
294
|
-
},
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
const res = new CustomGetCommand("key").exec(client)
|
|
298
|
-
```
|
|
299
55
|
|
|
300
|
-
|
|
56
|
+
// string
|
|
57
|
+
await redis.set('key', 'value');
|
|
58
|
+
let data = await redis.get('key');
|
|
59
|
+
console.log(data)
|
|
301
60
|
|
|
302
|
-
|
|
61
|
+
await redis.set('key2', 'value2', {ex: 1});
|
|
303
62
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
63
|
+
// sorted set
|
|
64
|
+
await redis.zadd('scores', { score: 1, member: 'team1' })
|
|
65
|
+
data = await redis.zrange('scores', 0, 100 )
|
|
66
|
+
console.log(data)
|
|
308
67
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
68
|
+
// list
|
|
69
|
+
await redis.lpush('elements', 'magnesium')
|
|
70
|
+
data = await redis.lrange('elements', 0, 100 )
|
|
71
|
+
console.log(data)
|
|
313
72
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
73
|
+
// hash
|
|
74
|
+
await redis.hset('people', {name: 'joe'})
|
|
75
|
+
data = await redis.hget('people', 'name' )
|
|
76
|
+
console.log(data)
|
|
317
77
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
78
|
+
// sets
|
|
79
|
+
await redis.sadd('animals', 'cat')
|
|
80
|
+
data = await redis.spop('animals', 1)
|
|
81
|
+
console.log(data)
|
|
321
82
|
```
|
|
322
83
|
|
|
323
|
-
|
|
324
|
-
initialized and the previously established connection to upstash is reused.
|
|
84
|
+
## Troubleshooting
|
|
325
85
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
deserializer will return them as string instead. This might cause a mismatch
|
|
331
|
-
with your custom types.
|
|
332
|
-
|
|
333
|
-
```ts
|
|
334
|
-
await redis.set("key", "101600000000150081467");
|
|
335
|
-
const res = await redis<number>("get");
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
In this example `res` will still be a string despite the type annotation. Please
|
|
339
|
-
keep that in mind and adjust accordingly.
|
|
86
|
+
We have a
|
|
87
|
+
[dedicated page](https://docs.upstash.com/redis/sdks/javascriptsdk/troubleshooting)
|
|
88
|
+
for common problems. If you can't find a solution, please
|
|
89
|
+
[open an issue](https://github.com/upstash/upstash-redis/issues/new).
|
|
340
90
|
|
|
341
91
|
## Docs
|
|
342
92
|
|
|
@@ -358,5 +108,18 @@ the url and token
|
|
|
358
108
|
UPSTASH_REDIS_REST_URL=".." UPSTASH_REDIS_REST_TOKEN=".." deno test -A
|
|
359
109
|
```
|
|
360
110
|
|
|
361
|
-
|
|
111
|
+
### Telemetry
|
|
112
|
+
|
|
113
|
+
This library sends anonymous telemetry data to help us improve your experience.
|
|
114
|
+
We collect the following:
|
|
115
|
+
|
|
116
|
+
- SDK version
|
|
117
|
+
- Platform (Deno, Cloudflare, Vercel)
|
|
118
|
+
- Runtime version (node@18.x)
|
|
119
|
+
|
|
120
|
+
You can opt out by setting the `UPSTASH_DISABLE_TELEMETRY` environment variable
|
|
121
|
+
to any truthy value.
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
UPSTASH_DISABLE_TELEMETRY=1
|
|
362
125
|
```
|
package/cloudflare.d.mts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './redis-e3e8473f.js';
|
|
2
|
+
export { c as Requester, U as UpstashRequest, d as UpstashResponse } from './redis-e3e8473f.js';
|
|
3
|
+
|
|
4
|
+
type Env = {
|
|
5
|
+
UPSTASH_DISABLE_TELEMETRY?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Connection credentials for upstash redis.
|
|
10
|
+
* Get them from https://console.upstash.com/redis/<uuid>
|
|
11
|
+
*/
|
|
12
|
+
type RedisConfigCloudflare = {
|
|
13
|
+
/**
|
|
14
|
+
* UPSTASH_REDIS_REST_URL
|
|
15
|
+
*/
|
|
16
|
+
url: string;
|
|
17
|
+
/**
|
|
18
|
+
* UPSTASH_REDIS_REST_TOKEN
|
|
19
|
+
*/
|
|
20
|
+
token: string;
|
|
21
|
+
} & RedisOptions & RequesterConfig & Env;
|
|
22
|
+
/**
|
|
23
|
+
* Serverless redis client for upstash.
|
|
24
|
+
*/
|
|
25
|
+
declare class Redis extends Redis$1 {
|
|
26
|
+
/**
|
|
27
|
+
* Create a new redis client
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const redis = new Redis({
|
|
32
|
+
* url: "<UPSTASH_REDIS_REST_URL>",
|
|
33
|
+
* token: "<UPSTASH_REDIS_REST_TOKEN>",
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
constructor(config: RedisConfigCloudflare, env?: Env);
|
|
38
|
+
static fromEnv(env?: {
|
|
39
|
+
UPSTASH_REDIS_REST_URL: string;
|
|
40
|
+
UPSTASH_REDIS_REST_TOKEN: string;
|
|
41
|
+
UPSTASH_DISABLE_TELEMETRY?: string;
|
|
42
|
+
}, opts?: Omit<RedisConfigCloudflare, "url" | "token">): Redis;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { Redis, RedisConfigCloudflare };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { R as RedisOptions, a as RequesterConfig, b as Redis$1 } from './redis-e3e8473f.js';
|
|
2
|
+
export { c as Requester, U as UpstashRequest, d as UpstashResponse } from './redis-e3e8473f.js';
|
|
3
|
+
|
|
4
|
+
type Env = {
|
|
5
|
+
UPSTASH_DISABLE_TELEMETRY?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
4
8
|
/**
|
|
5
9
|
* Connection credentials for upstash redis.
|
|
6
10
|
* Get them from https://console.upstash.com/redis/<uuid>
|
|
7
11
|
*/
|
|
8
|
-
|
|
12
|
+
type RedisConfigCloudflare = {
|
|
9
13
|
/**
|
|
10
14
|
* UPSTASH_REDIS_REST_URL
|
|
11
15
|
*/
|
|
@@ -14,15 +18,11 @@ export declare type RedisConfigCloudflare = {
|
|
|
14
18
|
* UPSTASH_REDIS_REST_TOKEN
|
|
15
19
|
*/
|
|
16
20
|
token: string;
|
|
17
|
-
|
|
18
|
-
* Configure the retry behaviour in case of network errors
|
|
19
|
-
*/
|
|
20
|
-
retry?: RetryConfig;
|
|
21
|
-
} & core.RedisOptions;
|
|
21
|
+
} & RedisOptions & RequesterConfig & Env;
|
|
22
22
|
/**
|
|
23
23
|
* Serverless redis client for upstash.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
declare class Redis extends Redis$1 {
|
|
26
26
|
/**
|
|
27
27
|
* Create a new redis client
|
|
28
28
|
*
|
|
@@ -34,9 +34,12 @@ export declare class Redis extends core.Redis {
|
|
|
34
34
|
* });
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
constructor(config: RedisConfigCloudflare);
|
|
37
|
+
constructor(config: RedisConfigCloudflare, env?: Env);
|
|
38
38
|
static fromEnv(env?: {
|
|
39
39
|
UPSTASH_REDIS_REST_URL: string;
|
|
40
40
|
UPSTASH_REDIS_REST_TOKEN: string;
|
|
41
|
+
UPSTASH_DISABLE_TELEMETRY?: string;
|
|
41
42
|
}, opts?: Omit<RedisConfigCloudflare, "url" | "token">): Redis;
|
|
42
43
|
}
|
|
44
|
+
|
|
45
|
+
export { Redis, RedisConfigCloudflare };
|