Skip to content

Commit c90c473

Browse files
committed
feat(command): add zadd zrem zrangewithscores
1 parent 560edc8 commit c90c473

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@litert/redis",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "A redis protocol implement for Node.js.",
55
"main": "./lib/index.js",
66
"scripts": {

src/lib/Commands.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,6 +2085,53 @@ export const COMMANDS: Record<keyof C.ICommandAPIs, ICommand> = {
20852085
}
20862086
},
20872087

2088+
/**
2089+
* Command: zRem
2090+
* @see https://redis.io/commands/zRem
2091+
*/
2092+
'zRem': {
2093+
prepare: createDefaultPreparer('ZREM')
2094+
},
2095+
2096+
/**
2097+
* Command: zAdd
2098+
* @see https://redis.io/commands/zAdd
2099+
*/
2100+
'zAdd': {
2101+
prepare: createDefaultPreparer('ZADD'),
2102+
process: isIntegerOne
2103+
},
2104+
2105+
/**
2106+
* Command: zRange
2107+
* @see https://redis.io/commands/zRange
2108+
*/
2109+
'zRangeWithScores': {
2110+
prepare: (key: string, start: number, stop: number) => {
2111+
2112+
return {
2113+
'cmd': 'ZRANGE',
2114+
'args': [key, start, stop, 'WITHSCORES']
2115+
};
2116+
},
2117+
process: U.pairList2NullableStringDict
2118+
},
2119+
2120+
/**
2121+
* Command: zRange
2122+
* @see https://redis.io/commands/zRange
2123+
*/
2124+
'zRangeWithScores$': {
2125+
prepare: (key: string, start: number, stop: number) => {
2126+
2127+
return {
2128+
'cmd': 'ZRANGE',
2129+
'args': [key, start, stop, 'WITHSCORES']
2130+
};
2131+
},
2132+
process: U.pairList2NullableBufferDict
2133+
},
2134+
20882135
/**
20892136
* Command: pfAdd
20902137
* @see https://redis.io/commands/pfAdd

src/lib/Common.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,30 @@ export interface ICommandAPIs {
12211221
*/
12221222
rPushX(key: string, values: Array<string | Buffer>): Promise<number>;
12231223

1224+
/**
1225+
* Command: zAdd
1226+
* @see https://redis.io/commands/zAdd
1227+
*/
1228+
zAdd(key: string, field: string, value: string | Buffer): Promise<boolean>;
1229+
1230+
/**
1231+
* Command: zRem
1232+
* @see https://redis.io/commands/zRem
1233+
*/
1234+
zRem(key: string, values: Array<string | Buffer>): Promise<number>;
1235+
1236+
/**
1237+
* Command: zRange
1238+
* @see https://redis.io/commands/zRange
1239+
*/
1240+
zRangeWithScores(key: string, start: number, stop: number): Promise<Record<string, string>>;
1241+
1242+
/**
1243+
* Command: zRange
1244+
* @see https://redis.io/commands/zRange
1245+
*/
1246+
zRangeWithScores$(key: string, start: number, stop: number): Promise<Record<string, Buffer>>;
1247+
12241248
/**
12251249
* Command: pfAdd
12261250
* @see https://redis.io/commands/pfAdd

0 commit comments

Comments
 (0)