@upstash/redis 1.0.0-alpha.2 → 1.0.0-alpha.7
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 +256 -0
- package/{dist/chunk-7YUZYRJS.mjs → chunk-7YUZYRJS.mjs} +0 -0
- package/{dist/chunk-FJSI5EBJ.mjs → chunk-AHCVU33N.mjs} +2 -2
- package/{dist/chunk-ZIB6XPPC.mjs → chunk-HGM7M7CJ.mjs} +9 -4
- package/{dist/chunk-U7OXAQMQ.mjs → chunk-HIDCSH5S.mjs} +0 -1
- package/{dist/chunk-Y5TC4HX2.mjs → chunk-T66TTHSV.mjs} +5 -5
- package/{dist/cloudflare.d.ts → cloudflare.d.ts} +2 -2
- package/{dist/cloudflare.js → cloudflare.js} +12 -9
- package/{dist/cloudflare.mjs → cloudflare.mjs} +3 -3
- package/{dist/commands.d.ts → commands.d.ts} +5 -3
- package/{dist/commands.js → commands.js} +10 -4
- package/{dist/commands.mjs → commands.mjs} +3 -1
- package/{dist/fastly.d.ts → fastly.d.ts} +2 -2
- package/{dist/fastly.js → fastly.js} +12 -9
- package/{dist/fastly.mjs → fastly.mjs} +3 -3
- package/{dist/http.d.ts → http.d.ts} +0 -0
- package/{dist/http.js → http.js} +0 -1
- package/{dist/http.mjs → http.mjs} +1 -1
- package/{dist/index.d.ts → index.d.ts} +2 -2
- package/{dist/index.js → index.js} +13 -10
- package/index.mjs +13 -0
- package/{dist/nodejs.d.ts → nodejs.d.ts} +2 -2
- package/{dist/nodejs.js → nodejs.js} +13 -10
- package/nodejs.mjs +10 -0
- package/package.json +1 -1
- package/{dist/redis-dd052782.d.ts → redis-71fa1ee6.d.ts} +7 -3
- package/{dist/zunionstore-dffa797d.d.ts → zunionstore-b38007ba.d.ts} +1 -1
- package/.eslintrc.js +0 -49
- package/.prettierrc.js +0 -7
- package/LICENSE +0 -21
- package/dist/index.mjs +0 -13
- package/dist/nodejs.mjs +0 -10
- package/dist/package.json +0 -1
- package/jest.config.js +0 -195
- package/pkg/cloudflare.ts +0 -77
- package/pkg/command.ts +0 -40
- package/pkg/commands/append.test.ts +0 -28
- package/pkg/commands/append.ts +0 -10
- package/pkg/commands/bitcount.test.ts +0 -36
- package/pkg/commands/bitcount.ts +0 -19
- package/pkg/commands/bitop.test.ts +0 -44
- package/pkg/commands/bitop.ts +0 -22
- package/pkg/commands/bitpos.test.ts +0 -26
- package/pkg/commands/bitpos.ts +0 -10
- package/pkg/commands/dbsize.test.ts +0 -17
- package/pkg/commands/dbsize.ts +0 -10
- package/pkg/commands/decr.test.ts +0 -22
- package/pkg/commands/decr.ts +0 -10
- package/pkg/commands/decrby.test.ts +0 -23
- package/pkg/commands/decrby.ts +0 -10
- package/pkg/commands/del.test.ts +0 -38
- package/pkg/commands/del.ts +0 -11
- package/pkg/commands/echo.test.ts +0 -11
- package/pkg/commands/echo.ts +0 -10
- package/pkg/commands/exists.test.ts +0 -37
- package/pkg/commands/exists.ts +0 -11
- package/pkg/commands/expire.test.ts +0 -22
- package/pkg/commands/expire.ts +0 -10
- package/pkg/commands/expireat.test.ts +0 -24
- package/pkg/commands/expireat.ts +0 -10
- package/pkg/commands/flushall.test.ts +0 -17
- package/pkg/commands/flushall.ts +0 -13
- package/pkg/commands/flushdb.test.ts +0 -17
- package/pkg/commands/flushdb.ts +0 -13
- package/pkg/commands/get.test.ts +0 -34
- package/pkg/commands/get.ts +0 -10
- package/pkg/commands/getbit.test.ts +0 -16
- package/pkg/commands/getbit.ts +0 -10
- package/pkg/commands/getrange.test.ts +0 -25
- package/pkg/commands/getrange.ts +0 -10
- package/pkg/commands/getset.test.ts +0 -33
- package/pkg/commands/getset.ts +0 -10
- package/pkg/commands/hdel.test.ts +0 -30
- package/pkg/commands/hdel.ts +0 -10
- package/pkg/commands/hexists.test.ts +0 -31
- package/pkg/commands/hexists.ts +0 -10
- package/pkg/commands/hget.test.ts +0 -47
- package/pkg/commands/hget.ts +0 -10
- package/pkg/commands/hgetall.test.ts +0 -32
- package/pkg/commands/hgetall.ts +0 -35
- package/pkg/commands/hincrby.test.ts +0 -27
- package/pkg/commands/hincrby.ts +0 -10
- package/pkg/commands/hincrbyfloat.test.ts +0 -25
- package/pkg/commands/hincrbyfloat.ts +0 -10
- package/pkg/commands/hkeys.test.ts +0 -22
- package/pkg/commands/hkeys.ts +0 -10
- package/pkg/commands/hlen.test.ts +0 -24
- package/pkg/commands/hlen.ts +0 -10
- package/pkg/commands/hmget.test.ts +0 -48
- package/pkg/commands/hmget.ts +0 -41
- package/pkg/commands/hmset.test.ts +0 -24
- package/pkg/commands/hmset.ts +0 -10
- package/pkg/commands/hscan.test.ts +0 -46
- package/pkg/commands/hscan.ts +0 -22
- package/pkg/commands/hset.test.ts +0 -21
- package/pkg/commands/hset.ts +0 -10
- package/pkg/commands/hsetnx.test.ts +0 -37
- package/pkg/commands/hsetnx.ts +0 -10
- package/pkg/commands/hstrlen.test.ts +0 -24
- package/pkg/commands/hstrlen.ts +0 -10
- package/pkg/commands/hvals.test.ts +0 -23
- package/pkg/commands/hvals.ts +0 -10
- package/pkg/commands/incr.test.ts +0 -23
- package/pkg/commands/incr.ts +0 -10
- package/pkg/commands/incrby.test.ts +0 -23
- package/pkg/commands/incrby.ts +0 -10
- package/pkg/commands/incrbyfloat.test.ts +0 -24
- package/pkg/commands/incrbyfloat.ts +0 -10
- package/pkg/commands/index.ts +0 -107
- package/pkg/commands/keys.test.ts +0 -17
- package/pkg/commands/keys.ts +0 -10
- package/pkg/commands/lindex.test.ts +0 -33
- package/pkg/commands/lindex.ts +0 -7
- package/pkg/commands/linsert.test.ts +0 -19
- package/pkg/commands/linsert.ts +0 -6
- package/pkg/commands/llen.test.ts +0 -26
- package/pkg/commands/llen.ts +0 -10
- package/pkg/commands/lpop.test.ts +0 -27
- package/pkg/commands/lpop.ts +0 -10
- package/pkg/commands/lpush.test.ts +0 -17
- package/pkg/commands/lpush.ts +0 -11
- package/pkg/commands/lpushx.test.ts +0 -29
- package/pkg/commands/lpushx.ts +0 -11
- package/pkg/commands/lrange.test.ts +0 -22
- package/pkg/commands/lrange.ts +0 -7
- package/pkg/commands/lrem.test.ts +0 -19
- package/pkg/commands/lrem.ts +0 -6
- package/pkg/commands/lset.test.ts +0 -40
- package/pkg/commands/lset.ts +0 -7
- package/pkg/commands/ltrim.test.ts +0 -29
- package/pkg/commands/ltrim.ts +0 -7
- package/pkg/commands/mget.test.ts +0 -44
- package/pkg/commands/mget.ts +0 -9
- package/pkg/commands/mset.test.ts +0 -24
- package/pkg/commands/mset.ts +0 -10
- package/pkg/commands/msetnx.test.ts +0 -46
- package/pkg/commands/msetnx.ts +0 -10
- package/pkg/commands/persist.test.ts +0 -22
- package/pkg/commands/persist.ts +0 -10
- package/pkg/commands/pexpire.test.ts +0 -24
- package/pkg/commands/pexpire.ts +0 -10
- package/pkg/commands/pexpireat.test.ts +0 -24
- package/pkg/commands/pexpireat.ts +0 -10
- package/pkg/commands/ping.test.ts +0 -19
- package/pkg/commands/ping.ts +0 -13
- package/pkg/commands/psetex.test.ts +0 -23
- package/pkg/commands/psetex.ts +0 -10
- package/pkg/commands/pttl.test.ts +0 -17
- package/pkg/commands/pttl.ts +0 -10
- package/pkg/commands/randomkey.test.ts +0 -17
- package/pkg/commands/randomkey.ts +0 -10
- package/pkg/commands/rename.test.ts +0 -18
- package/pkg/commands/rename.ts +0 -10
- package/pkg/commands/renamenx.test.ts +0 -32
- package/pkg/commands/renamenx.ts +0 -10
- package/pkg/commands/rpop.test.ts +0 -27
- package/pkg/commands/rpop.ts +0 -10
- package/pkg/commands/rpush.test.ts +0 -17
- package/pkg/commands/rpush.ts +0 -11
- package/pkg/commands/rpushx.test.ts +0 -29
- package/pkg/commands/rpushx.ts +0 -11
- package/pkg/commands/sadd.test.ts +0 -16
- package/pkg/commands/sadd.ts +0 -11
- package/pkg/commands/scan.test.ts +0 -50
- package/pkg/commands/scan.ts +0 -21
- package/pkg/commands/scard.test.ts +0 -15
- package/pkg/commands/scard.ts +0 -9
- package/pkg/commands/sdiff.test.ts +0 -20
- package/pkg/commands/sdiff.ts +0 -9
- package/pkg/commands/sdiffstore.test.ts +0 -21
- package/pkg/commands/sdiffstore.ts +0 -10
- package/pkg/commands/set.test.ts +0 -112
- package/pkg/commands/set.ts +0 -53
- package/pkg/commands/setbit.test.ts +0 -16
- package/pkg/commands/setbit.ts +0 -10
- package/pkg/commands/setex.test.ts +0 -22
- package/pkg/commands/setex.ts +0 -10
- package/pkg/commands/setnx.test.ts +0 -27
- package/pkg/commands/setnx.ts +0 -10
- package/pkg/commands/setrange.test.ts +0 -25
- package/pkg/commands/setrange.ts +0 -10
- package/pkg/commands/sinter.test.ts +0 -36
- package/pkg/commands/sinter.ts +0 -9
- package/pkg/commands/sinterstore.test.ts +0 -21
- package/pkg/commands/sinterstore.ts +0 -9
- package/pkg/commands/sismember.test.ts +0 -30
- package/pkg/commands/sismember.ts +0 -9
- package/pkg/commands/smembers.test.ts +0 -22
- package/pkg/commands/smembers.ts +0 -10
- package/pkg/commands/smove.test.ts +0 -18
- package/pkg/commands/smove.ts +0 -9
- package/pkg/commands/spop.test.ts +0 -35
- package/pkg/commands/spop.ts +0 -13
- package/pkg/commands/srandmember.test.ts +0 -32
- package/pkg/commands/srandmember.ts +0 -13
- package/pkg/commands/srem.test.ts +0 -18
- package/pkg/commands/srem.ts +0 -10
- package/pkg/commands/sscan.test.ts +0 -50
- package/pkg/commands/sscan.ts +0 -22
- package/pkg/commands/strlen.test.ts +0 -16
- package/pkg/commands/strlen.ts +0 -10
- package/pkg/commands/sunion.test.ts +0 -22
- package/pkg/commands/sunion.ts +0 -10
- package/pkg/commands/sunionstore.test.ts +0 -29
- package/pkg/commands/sunionstore.ts +0 -10
- package/pkg/commands/time.test.ts +0 -11
- package/pkg/commands/time.ts +0 -9
- package/pkg/commands/touch.test.ts +0 -20
- package/pkg/commands/touch.ts +0 -10
- package/pkg/commands/ttl.test.ts +0 -17
- package/pkg/commands/ttl.ts +0 -10
- package/pkg/commands/type.test.ts +0 -72
- package/pkg/commands/type.ts +0 -11
- package/pkg/commands/unlink.test.ts +0 -21
- package/pkg/commands/unlink.ts +0 -10
- package/pkg/commands/zadd.test.ts +0 -177
- package/pkg/commands/zadd.ts +0 -64
- package/pkg/commands/zcard.test.ts +0 -15
- package/pkg/commands/zcard.ts +0 -10
- package/pkg/commands/zcount.test.ts +0 -15
- package/pkg/commands/zcount.ts +0 -9
- package/pkg/commands/zincrby.test.ts +0 -20
- package/pkg/commands/zincrby.ts +0 -9
- package/pkg/commands/zinterstore.test.ts +0 -239
- package/pkg/commands/zinterstore.ts +0 -55
- package/pkg/commands/zlexcount.test.ts +0 -22
- package/pkg/commands/zlexcount.ts +0 -9
- package/pkg/commands/zpopmax.test.ts +0 -45
- package/pkg/commands/zpopmax.ts +0 -13
- package/pkg/commands/zpopmin.test.ts +0 -49
- package/pkg/commands/zpopmin.ts +0 -13
- package/pkg/commands/zrange.test.ts +0 -52
- package/pkg/commands/zrange.ts +0 -22
- package/pkg/commands/zrank.test.ts +0 -22
- package/pkg/commands/zrank.ts +0 -10
- package/pkg/commands/zrem.test.ts +0 -20
- package/pkg/commands/zrem.ts +0 -10
- package/pkg/commands/zremrangebylex.test.ts +0 -26
- package/pkg/commands/zremrangebylex.ts +0 -9
- package/pkg/commands/zremrangebyrank.test.ts +0 -27
- package/pkg/commands/zremrangebyrank.ts +0 -9
- package/pkg/commands/zremrangebyscore.test.ts +0 -24
- package/pkg/commands/zremrangebyscore.ts +0 -9
- package/pkg/commands/zrevrank.test.ts +0 -22
- package/pkg/commands/zrevrank.ts +0 -10
- package/pkg/commands/zscan.test.ts +0 -50
- package/pkg/commands/zscan.ts +0 -22
- package/pkg/commands/zscore.test.ts +0 -18
- package/pkg/commands/zscore.ts +0 -10
- package/pkg/commands/zunionstore.test.ts +0 -215
- package/pkg/commands/zunionstore.ts +0 -55
- package/pkg/commands/zz.ts +0 -1
- package/pkg/error.ts +0 -9
- package/pkg/fastly.ts +0 -54
- package/pkg/http.test.ts +0 -34
- package/pkg/http.ts +0 -62
- package/pkg/index.ts +0 -2
- package/pkg/nodejs.ts +0 -83
- package/pkg/pipeline.test.ts +0 -177
- package/pkg/pipeline.ts +0 -999
- package/pkg/redis.ts +0 -930
- package/pkg/test-utils.ts +0 -41
- package/pkg/types.ts +0 -4
- package/pkg/util.ts +0 -22
- package/pnpm-lock.yaml +0 -3940
- package/tsconfig.json +0 -100
- package/tsconfig.module.json +0 -8
- package/tsup.config.ts +0 -16
package/pkg/commands/hset.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from "../command"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @see https://redis.io/commands/hset
|
|
5
|
-
*/
|
|
6
|
-
export class HSetCommand<TData> extends Command<number, number> {
|
|
7
|
-
constructor(key: string, field: string, value: TData) {
|
|
8
|
-
super(["hset", key, field, value])
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { describe, it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { HSetCommand } from "./hset"
|
|
5
|
-
import { HGetCommand } from "./hget"
|
|
6
|
-
import { HSetNXCommand } from "./hsetnx"
|
|
7
|
-
const client = newHttpClient()
|
|
8
|
-
|
|
9
|
-
const { newKey, cleanup } = keygen()
|
|
10
|
-
afterAll(cleanup)
|
|
11
|
-
|
|
12
|
-
describe("when hash exists already", () => {
|
|
13
|
-
it("returns 0", async () => {
|
|
14
|
-
const key = newKey()
|
|
15
|
-
const field = randomUUID()
|
|
16
|
-
const value = randomUUID()
|
|
17
|
-
const newValue = randomUUID()
|
|
18
|
-
await new HSetCommand(key, field, value).exec(client)
|
|
19
|
-
const res = await new HSetNXCommand(key, field, newValue).exec(client)
|
|
20
|
-
expect(res).toBe(0)
|
|
21
|
-
const res2 = await new HGetCommand(key, field).exec(client)
|
|
22
|
-
|
|
23
|
-
expect(res2).toEqual(value)
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
describe("when hash does not exist", () => {
|
|
27
|
-
it("returns 1", async () => {
|
|
28
|
-
const key = newKey()
|
|
29
|
-
const field = randomUUID()
|
|
30
|
-
const value = randomUUID()
|
|
31
|
-
const res = await new HSetNXCommand(key, field, value).exec(client)
|
|
32
|
-
expect(res).toBe(1)
|
|
33
|
-
const res2 = await new HGetCommand(key, field).exec(client)
|
|
34
|
-
|
|
35
|
-
expect(res2).toEqual(value)
|
|
36
|
-
})
|
|
37
|
-
})
|
package/pkg/commands/hsetnx.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from "../command"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @see https://redis.io/commands/hsetnx
|
|
5
|
-
*/
|
|
6
|
-
export class HSetNXCommand<TData> extends Command<0 | 1, "0" | "1"> {
|
|
7
|
-
constructor(key: string, field: string, value: TData) {
|
|
8
|
-
super(["hsetnx", key, field, value])
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
|
|
5
|
-
import { HStrLenCommand } from "./hstrlen"
|
|
6
|
-
import { HSetCommand } from "./hset"
|
|
7
|
-
|
|
8
|
-
const client = newHttpClient()
|
|
9
|
-
|
|
10
|
-
const { newKey, cleanup } = keygen()
|
|
11
|
-
afterAll(cleanup)
|
|
12
|
-
it("returns correct length", async () => {
|
|
13
|
-
const key = newKey()
|
|
14
|
-
const field = randomUUID()
|
|
15
|
-
const value = randomUUID()
|
|
16
|
-
|
|
17
|
-
const res = await new HStrLenCommand(key, field).exec(client)
|
|
18
|
-
expect(res).toBe(0)
|
|
19
|
-
await new HSetCommand(key, field, value).exec(client)
|
|
20
|
-
|
|
21
|
-
const res2 = await new HStrLenCommand(key, field).exec(client)
|
|
22
|
-
|
|
23
|
-
expect(res2).toBe(36)
|
|
24
|
-
})
|
package/pkg/commands/hstrlen.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { HValsCommand } from "./hvals"
|
|
5
|
-
import { HSetCommand } from "./hset"
|
|
6
|
-
const client = newHttpClient()
|
|
7
|
-
|
|
8
|
-
const { newKey, cleanup } = keygen()
|
|
9
|
-
afterAll(cleanup)
|
|
10
|
-
|
|
11
|
-
it("returns correct length", async () => {
|
|
12
|
-
const key = newKey()
|
|
13
|
-
const field = randomUUID()
|
|
14
|
-
const value = randomUUID()
|
|
15
|
-
|
|
16
|
-
const res = await new HValsCommand(key).exec(client)
|
|
17
|
-
expect(res).toEqual([])
|
|
18
|
-
await new HSetCommand(key, field, value).exec(client)
|
|
19
|
-
|
|
20
|
-
const res2 = await new HValsCommand(key).exec(client)
|
|
21
|
-
|
|
22
|
-
expect(res2).toEqual([value])
|
|
23
|
-
})
|
package/pkg/commands/hvals.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
3
|
-
import { SetCommand } from "./set"
|
|
4
|
-
import { IncrCommand } from "./incr"
|
|
5
|
-
const client = newHttpClient()
|
|
6
|
-
|
|
7
|
-
const { newKey, cleanup } = keygen()
|
|
8
|
-
afterAll(cleanup)
|
|
9
|
-
|
|
10
|
-
it("increments a non-existing value", async () => {
|
|
11
|
-
const key = newKey()
|
|
12
|
-
const res = await new IncrCommand(key).exec(client)
|
|
13
|
-
|
|
14
|
-
expect(res).toEqual(1)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it("increments and existing value", async () => {
|
|
18
|
-
const key = newKey()
|
|
19
|
-
await new SetCommand(key, 4).exec(client)
|
|
20
|
-
const res = await new IncrCommand(key).exec(client)
|
|
21
|
-
|
|
22
|
-
expect(res).toEqual(5)
|
|
23
|
-
})
|
package/pkg/commands/incr.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
3
|
-
import { IncrByCommand } from "./incrby"
|
|
4
|
-
import { SetCommand } from "./set"
|
|
5
|
-
const client = newHttpClient()
|
|
6
|
-
|
|
7
|
-
const { newKey, cleanup } = keygen()
|
|
8
|
-
afterAll(cleanup)
|
|
9
|
-
|
|
10
|
-
it("increments a non-existing value", async () => {
|
|
11
|
-
const key = newKey()
|
|
12
|
-
const res = await new IncrByCommand(key, 2).exec(client)
|
|
13
|
-
|
|
14
|
-
expect(res).toEqual(2)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it("increments and existing value", async () => {
|
|
18
|
-
const key = newKey()
|
|
19
|
-
await new SetCommand(key, 5).exec(client)
|
|
20
|
-
const res = await new IncrByCommand(key, 2).exec(client)
|
|
21
|
-
|
|
22
|
-
expect(res).toEqual(7)
|
|
23
|
-
})
|
package/pkg/commands/incrby.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
3
|
-
import { SetCommand } from "./set"
|
|
4
|
-
|
|
5
|
-
import { IncrByFloatCommand } from "./incrbyfloat"
|
|
6
|
-
const client = newHttpClient()
|
|
7
|
-
|
|
8
|
-
const { newKey, cleanup } = keygen()
|
|
9
|
-
afterAll(cleanup)
|
|
10
|
-
|
|
11
|
-
it("increments a non-existing value", async () => {
|
|
12
|
-
const key = newKey()
|
|
13
|
-
const res = await new IncrByFloatCommand(key, 2.5).exec(client)
|
|
14
|
-
|
|
15
|
-
expect(res).toEqual(2.5)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it("increments and existing value", async () => {
|
|
19
|
-
const key = newKey()
|
|
20
|
-
await new SetCommand(key, 5).exec(client)
|
|
21
|
-
const res = await new IncrByFloatCommand(key, 2.5).exec(client)
|
|
22
|
-
|
|
23
|
-
expect(res).toEqual(7.5)
|
|
24
|
-
})
|
package/pkg/commands/index.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
export * from "./append"
|
|
2
|
-
export * from "./bitcount"
|
|
3
|
-
export * from "./bitop"
|
|
4
|
-
export * from "./bitpos"
|
|
5
|
-
export * from "./dbsize"
|
|
6
|
-
export * from "./decr"
|
|
7
|
-
export * from "./decrby"
|
|
8
|
-
export * from "./del"
|
|
9
|
-
export * from "./echo"
|
|
10
|
-
export * from "./exists"
|
|
11
|
-
export * from "./expire"
|
|
12
|
-
export * from "./expireat"
|
|
13
|
-
export * from "./flushall"
|
|
14
|
-
export * from "./flushdb"
|
|
15
|
-
export * from "./get"
|
|
16
|
-
export * from "./getbit"
|
|
17
|
-
export * from "./getrange"
|
|
18
|
-
export * from "./getset"
|
|
19
|
-
export * from "./hdel"
|
|
20
|
-
export * from "./hexists"
|
|
21
|
-
export * from "./hget"
|
|
22
|
-
export * from "./hgetall"
|
|
23
|
-
export * from "./hincrby"
|
|
24
|
-
export * from "./hincrbyfloat"
|
|
25
|
-
export * from "./hkeys"
|
|
26
|
-
export * from "./hlen"
|
|
27
|
-
export * from "./hmget"
|
|
28
|
-
export * from "./hmset"
|
|
29
|
-
export * from "./hscan"
|
|
30
|
-
export * from "./hset"
|
|
31
|
-
export * from "./hsetnx"
|
|
32
|
-
export * from "./hstrlen"
|
|
33
|
-
export * from "./hvals"
|
|
34
|
-
export * from "./incr"
|
|
35
|
-
export * from "./incrby"
|
|
36
|
-
export * from "./incrbyfloat"
|
|
37
|
-
export * from "./keys"
|
|
38
|
-
export * from "./lindex"
|
|
39
|
-
export * from "./linsert"
|
|
40
|
-
export * from "./llen"
|
|
41
|
-
export * from "./lpop"
|
|
42
|
-
export * from "./lpush"
|
|
43
|
-
export * from "./lpushx"
|
|
44
|
-
export * from "./lrange"
|
|
45
|
-
export * from "./lrem"
|
|
46
|
-
export * from "./lset"
|
|
47
|
-
export * from "./ltrim"
|
|
48
|
-
export * from "./mget"
|
|
49
|
-
export * from "./mset"
|
|
50
|
-
export * from "./msetnx"
|
|
51
|
-
export * from "./persist"
|
|
52
|
-
export * from "./pexpire"
|
|
53
|
-
export * from "./pexpireat"
|
|
54
|
-
export * from "./ping"
|
|
55
|
-
export * from "./psetex"
|
|
56
|
-
export * from "./pttl"
|
|
57
|
-
export * from "./randomkey"
|
|
58
|
-
export * from "./rename"
|
|
59
|
-
export * from "./renamenx"
|
|
60
|
-
export * from "./rpop"
|
|
61
|
-
export * from "./rpush"
|
|
62
|
-
export * from "./rpushx"
|
|
63
|
-
export * from "./sadd"
|
|
64
|
-
export * from "./scan"
|
|
65
|
-
export * from "./scard"
|
|
66
|
-
export * from "./sdiff"
|
|
67
|
-
export * from "./sdiffstore"
|
|
68
|
-
export * from "./set"
|
|
69
|
-
export * from "./setbit"
|
|
70
|
-
export * from "./setex"
|
|
71
|
-
export * from "./setnx"
|
|
72
|
-
export * from "./setrange"
|
|
73
|
-
export * from "./sinter"
|
|
74
|
-
export * from "./sinterstore"
|
|
75
|
-
export * from "./sismember"
|
|
76
|
-
export * from "./smembers"
|
|
77
|
-
export * from "./smove"
|
|
78
|
-
export * from "./spop"
|
|
79
|
-
export * from "./srandmember"
|
|
80
|
-
export * from "./srem"
|
|
81
|
-
export * from "./sscan"
|
|
82
|
-
export * from "./strlen"
|
|
83
|
-
export * from "./sunion"
|
|
84
|
-
export * from "./sunionstore"
|
|
85
|
-
export * from "./time"
|
|
86
|
-
export * from "./touch"
|
|
87
|
-
export * from "./ttl"
|
|
88
|
-
export * from "./type"
|
|
89
|
-
export * from "./unlink"
|
|
90
|
-
export * from "./zadd"
|
|
91
|
-
export * from "./zcard"
|
|
92
|
-
export * from "./zcount"
|
|
93
|
-
export * from "./zincrby"
|
|
94
|
-
export * from "./zinterstore"
|
|
95
|
-
export * from "./zlexcount"
|
|
96
|
-
export * from "./zpopmax"
|
|
97
|
-
export * from "./zpopmin"
|
|
98
|
-
export * from "./zrange"
|
|
99
|
-
export * from "./zrank"
|
|
100
|
-
export * from "./zrem"
|
|
101
|
-
export * from "./zremrangebylex"
|
|
102
|
-
export * from "./zremrangebyrank"
|
|
103
|
-
export * from "./zremrangebyscore"
|
|
104
|
-
export * from "./zrevrank"
|
|
105
|
-
export * from "./zscan"
|
|
106
|
-
export * from "./zscore"
|
|
107
|
-
export * from "./zunionstore"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { describe, it, expect, afterAll } from "@jest/globals"
|
|
3
|
-
import { SetCommand } from "./set"
|
|
4
|
-
import { KeysCommand } from "./keys"
|
|
5
|
-
const client = newHttpClient()
|
|
6
|
-
|
|
7
|
-
const { newKey, cleanup } = keygen()
|
|
8
|
-
afterAll(cleanup)
|
|
9
|
-
|
|
10
|
-
describe("when keys are found", () => {
|
|
11
|
-
it("returns keys", async () => {
|
|
12
|
-
const key = newKey()
|
|
13
|
-
await new SetCommand(key, "value").exec(client)
|
|
14
|
-
const res = await new KeysCommand(key).exec(client)
|
|
15
|
-
expect(res).toEqual([key])
|
|
16
|
-
})
|
|
17
|
-
})
|
package/pkg/commands/keys.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { describe, it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { LPushCommand } from "./lpush"
|
|
5
|
-
import { LIndexCommand } from "./lindex"
|
|
6
|
-
|
|
7
|
-
const client = newHttpClient()
|
|
8
|
-
|
|
9
|
-
const { newKey, cleanup } = keygen()
|
|
10
|
-
afterAll(cleanup)
|
|
11
|
-
|
|
12
|
-
describe("when list exists", () => {
|
|
13
|
-
describe("when the index is in range", () => {
|
|
14
|
-
it("returns the element at index", async () => {
|
|
15
|
-
const key = newKey()
|
|
16
|
-
|
|
17
|
-
const value = randomUUID()
|
|
18
|
-
await new LPushCommand(key, value).exec(client)
|
|
19
|
-
const res = await new LIndexCommand(key, 0).exec(client)
|
|
20
|
-
expect(res).toEqual(value)
|
|
21
|
-
})
|
|
22
|
-
describe("when the index is out of bounds", () => {
|
|
23
|
-
it("returns null", async () => {
|
|
24
|
-
const key = newKey()
|
|
25
|
-
|
|
26
|
-
const value = randomUUID()
|
|
27
|
-
await new LPushCommand(key, value).exec(client)
|
|
28
|
-
const res = await new LIndexCommand(key, 1).exec(client)
|
|
29
|
-
expect(res).toBeNull()
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
})
|
package/pkg/commands/lindex.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { LInsertCommand } from "./linsert"
|
|
5
|
-
import { LPushCommand } from "./lpush"
|
|
6
|
-
const client = newHttpClient()
|
|
7
|
-
|
|
8
|
-
const { newKey, cleanup } = keygen()
|
|
9
|
-
afterAll(cleanup)
|
|
10
|
-
|
|
11
|
-
it("adds the element", async () => {
|
|
12
|
-
const key = newKey()
|
|
13
|
-
const value1 = randomUUID()
|
|
14
|
-
const value2 = randomUUID()
|
|
15
|
-
|
|
16
|
-
await new LPushCommand(key, value1).exec(client)
|
|
17
|
-
const res = await new LInsertCommand(key, "before", value1, value2).exec(client)
|
|
18
|
-
expect(res).toBe(2)
|
|
19
|
-
})
|
package/pkg/commands/linsert.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { describe, it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { LLenCommand } from "./llen"
|
|
5
|
-
import { LPushCommand } from "./lpush"
|
|
6
|
-
const client = newHttpClient()
|
|
7
|
-
|
|
8
|
-
const { newKey, cleanup } = keygen()
|
|
9
|
-
afterAll(cleanup)
|
|
10
|
-
|
|
11
|
-
describe("when list exists", () => {
|
|
12
|
-
it("returns the length of the list", async () => {
|
|
13
|
-
const key = newKey()
|
|
14
|
-
await new LPushCommand(key, randomUUID()).exec(client)
|
|
15
|
-
const res = await new LLenCommand(key).exec(client)
|
|
16
|
-
expect(res).toEqual(1)
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
describe("when list does not exist", () => {
|
|
21
|
-
it("returns 0", async () => {
|
|
22
|
-
const key = newKey()
|
|
23
|
-
const res = await new LLenCommand(key).exec(client)
|
|
24
|
-
expect(res).toEqual(0)
|
|
25
|
-
})
|
|
26
|
-
})
|
package/pkg/commands/llen.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { describe, it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { LPopCommand } from "./lpop"
|
|
5
|
-
import { LPushCommand } from "./lpush"
|
|
6
|
-
const client = newHttpClient()
|
|
7
|
-
|
|
8
|
-
const { newKey, cleanup } = keygen()
|
|
9
|
-
afterAll(cleanup)
|
|
10
|
-
|
|
11
|
-
describe("when list exists", () => {
|
|
12
|
-
it("returns the first element", async () => {
|
|
13
|
-
const key = newKey()
|
|
14
|
-
const value = randomUUID()
|
|
15
|
-
await new LPushCommand(key, value).exec(client)
|
|
16
|
-
const res = await new LPopCommand(key).exec(client)
|
|
17
|
-
expect(res).toEqual(value)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
describe("when list does not exist", () => {
|
|
22
|
-
it("returns null", async () => {
|
|
23
|
-
const key = newKey()
|
|
24
|
-
const res = await new LPopCommand(key).exec(client)
|
|
25
|
-
expect(res).toBeNull()
|
|
26
|
-
})
|
|
27
|
-
})
|
package/pkg/commands/lpop.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { LPushCommand } from "./lpush"
|
|
5
|
-
const client = newHttpClient()
|
|
6
|
-
|
|
7
|
-
const { newKey, cleanup } = keygen()
|
|
8
|
-
afterAll(cleanup)
|
|
9
|
-
|
|
10
|
-
it("returns the length after command", async () => {
|
|
11
|
-
const key = newKey()
|
|
12
|
-
const res = await new LPushCommand(key, randomUUID()).exec(client)
|
|
13
|
-
expect(res).toEqual(1)
|
|
14
|
-
const res2 = await new LPushCommand(key, randomUUID(), randomUUID()).exec(client)
|
|
15
|
-
|
|
16
|
-
expect(res2).toEqual(3)
|
|
17
|
-
})
|
package/pkg/commands/lpush.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NonEmptyArray } from "../types"
|
|
2
|
-
import { Command } from "../command"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @see https://redis.io/commands/lpush
|
|
6
|
-
*/
|
|
7
|
-
export class LPushCommand<TData = string> extends Command<number, number> {
|
|
8
|
-
constructor(key: string, ...elements: NonEmptyArray<TData>) {
|
|
9
|
-
super(["lpush", key, ...elements])
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { describe, it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { LPushXCommand } from "./lpushx"
|
|
5
|
-
import { LPushCommand } from "./lpush"
|
|
6
|
-
const client = newHttpClient()
|
|
7
|
-
|
|
8
|
-
const { newKey, cleanup } = keygen()
|
|
9
|
-
afterAll(cleanup)
|
|
10
|
-
|
|
11
|
-
describe("when list exists", () => {
|
|
12
|
-
it("returns the length after command", async () => {
|
|
13
|
-
const key = newKey()
|
|
14
|
-
await new LPushCommand(key, randomUUID()).exec(client)
|
|
15
|
-
const res = await new LPushXCommand(key, randomUUID()).exec(client)
|
|
16
|
-
expect(res).toEqual(2)
|
|
17
|
-
const res2 = await new LPushXCommand(key, randomUUID(), randomUUID()).exec(client)
|
|
18
|
-
|
|
19
|
-
expect(res2).toEqual(4)
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
describe("when list does not exist", () => {
|
|
24
|
-
it("does nothing", async () => {
|
|
25
|
-
const key = newKey()
|
|
26
|
-
const res = await new LPushXCommand(key, randomUUID()).exec(client)
|
|
27
|
-
expect(res).toEqual(0)
|
|
28
|
-
})
|
|
29
|
-
})
|
package/pkg/commands/lpushx.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NonEmptyArray } from "../types"
|
|
2
|
-
import { Command } from "../command"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @see https://redis.io/commands/lpushx
|
|
6
|
-
*/
|
|
7
|
-
export class LPushXCommand<TData> extends Command<number, number> {
|
|
8
|
-
constructor(key: string, ...elements: NonEmptyArray<TData>) {
|
|
9
|
-
super(["lpushx", key, ...elements])
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { randomUUID } from "crypto"
|
|
3
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
4
|
-
import { RPushCommand } from "./rpush"
|
|
5
|
-
import { LRangeCommand } from "./lrange"
|
|
6
|
-
const client = newHttpClient()
|
|
7
|
-
|
|
8
|
-
const { newKey, cleanup } = keygen()
|
|
9
|
-
afterAll(cleanup)
|
|
10
|
-
|
|
11
|
-
it("returns the correct range", async () => {
|
|
12
|
-
const key = newKey()
|
|
13
|
-
const value1 = randomUUID()
|
|
14
|
-
const value2 = randomUUID()
|
|
15
|
-
const value3 = randomUUID()
|
|
16
|
-
await new RPushCommand(key, value1, value2, value3).exec(client)
|
|
17
|
-
const res = await new LRangeCommand(key, 1, 2).exec(client)
|
|
18
|
-
expect(res).toBeDefined()
|
|
19
|
-
expect(res!.length).toEqual(2)
|
|
20
|
-
expect(res![0]).toEqual(value2)
|
|
21
|
-
expect(res![1]).toEqual(value3)
|
|
22
|
-
})
|
package/pkg/commands/lrange.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { keygen, newHttpClient } from "../test-utils"
|
|
2
|
-
import { it, expect, afterAll } from "@jest/globals"
|
|
3
|
-
|
|
4
|
-
import { LPushCommand } from "./lpush"
|
|
5
|
-
import { LRemCommand } from "./lrem"
|
|
6
|
-
const client = newHttpClient()
|
|
7
|
-
|
|
8
|
-
const { newKey, cleanup } = keygen()
|
|
9
|
-
afterAll(cleanup)
|
|
10
|
-
|
|
11
|
-
it("returns the number of deleted elements", async () => {
|
|
12
|
-
const key = newKey()
|
|
13
|
-
await new LPushCommand(key, "element").exec(client)
|
|
14
|
-
await new LPushCommand(key, "element").exec(client)
|
|
15
|
-
await new LPushCommand(key, "something else").exec(client)
|
|
16
|
-
|
|
17
|
-
const res = await new LRemCommand(key, 2, "element").exec(client)
|
|
18
|
-
expect(res).toBe(2)
|
|
19
|
-
})
|