@m3ftwz/redisfx 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/Redis.d.ts +90 -0
- package/Redis.js +291 -0
- package/Redis.js.map +1 -0
- package/Redis.ts +413 -0
- package/package.json +25 -0
- package/tsconfig.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# RedisFX exports wrapper for FiveM
|
|
2
|
+
|
|
3
|
+
Types are fully supported and you will get intellisense on the `redisfx` object when using it.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
# With pnpm
|
|
9
|
+
pnpm add @m3ftwz/redisfx
|
|
10
|
+
|
|
11
|
+
# With Yarn
|
|
12
|
+
yarn add @m3ftwz/redisfx
|
|
13
|
+
|
|
14
|
+
# With npm
|
|
15
|
+
npm install @m3ftwz/redisfx
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Import as module:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { redisfx } from '@m3ftwz/redisfx';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Import with require:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
const { redisfx } = require('@m3ftwz/redisfx');
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Examples
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
// Callback style
|
|
36
|
+
redisfx.get('player:1:name', (result) => {
|
|
37
|
+
console.log(result)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Promise style
|
|
41
|
+
redisfx.get('player:1:name').then((result) => {
|
|
42
|
+
console.log(result)
|
|
43
|
+
}).catch(console.error)
|
|
44
|
+
|
|
45
|
+
// Async/await
|
|
46
|
+
const result = await redisfx.get('player:1:name').catch(console.error)
|
|
47
|
+
console.log(result)
|
|
48
|
+
|
|
49
|
+
// Hash operations
|
|
50
|
+
await redisfx.hset('player:1', 'money', 1000)
|
|
51
|
+
const money = await redisfx.hget('player:1', 'money')
|
|
52
|
+
|
|
53
|
+
// Set with expiry
|
|
54
|
+
await redisfx.set('session:abc', 'data', { EX: 3600 })
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
LGPL-3.0
|
package/Redis.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
type Callback<T> = (result: T | null) => void;
|
|
2
|
+
interface SetOptions {
|
|
3
|
+
EX?: number;
|
|
4
|
+
PX?: number;
|
|
5
|
+
EXAT?: number;
|
|
6
|
+
PXAT?: number;
|
|
7
|
+
NX?: boolean;
|
|
8
|
+
XX?: boolean;
|
|
9
|
+
KEEPTTL?: boolean;
|
|
10
|
+
GET?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface ZAddOptions {
|
|
13
|
+
NX?: boolean;
|
|
14
|
+
XX?: boolean;
|
|
15
|
+
GT?: boolean;
|
|
16
|
+
LT?: boolean;
|
|
17
|
+
CH?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface ScanOptions {
|
|
20
|
+
MATCH?: string;
|
|
21
|
+
COUNT?: number;
|
|
22
|
+
}
|
|
23
|
+
interface RedisFX {
|
|
24
|
+
isReady: () => boolean;
|
|
25
|
+
awaitConnection: () => Promise<true>;
|
|
26
|
+
ready: (callback: () => void) => void;
|
|
27
|
+
get: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
28
|
+
set: <T = string | null>(key: string, value: string | number, options?: SetOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
|
|
29
|
+
del: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
30
|
+
exists: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
31
|
+
expire: <T = number>(key: string, seconds: number, cb?: Callback<T>) => Promise<T>;
|
|
32
|
+
ttl: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
33
|
+
incr: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
34
|
+
incrby: <T = number>(key: string, increment: number, cb?: Callback<T>) => Promise<T>;
|
|
35
|
+
decr: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
36
|
+
decrby: <T = number>(key: string, decrement: number, cb?: Callback<T>) => Promise<T>;
|
|
37
|
+
mget: <T = (string | null)[]>(keys: string[], cb?: Callback<T>) => Promise<T>;
|
|
38
|
+
mset: <T = string>(keyValues: Record<string, string | number>, cb?: Callback<T>) => Promise<T>;
|
|
39
|
+
hget: <T = string | null>(key: string, field: string, cb?: Callback<T>) => Promise<T>;
|
|
40
|
+
hset: <T = number>(key: string, field: string, value: string | number, cb?: Callback<T>) => Promise<T>;
|
|
41
|
+
hmset: <T = number>(key: string, fieldValues: Record<string, string | number>, cb?: Callback<T>) => Promise<T>;
|
|
42
|
+
hgetall: <T = Record<string, string>>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
43
|
+
hdel: <T = number>(key: string, fields: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
44
|
+
hincrby: <T = number>(key: string, field: string, increment: number, cb?: Callback<T>) => Promise<T>;
|
|
45
|
+
hexists: <T = number>(key: string, field: string, cb?: Callback<T>) => Promise<T>;
|
|
46
|
+
hkeys: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
47
|
+
hvals: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
48
|
+
hlen: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
49
|
+
lpush: <T = number>(key: string, values: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
50
|
+
rpush: <T = number>(key: string, values: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
51
|
+
lpop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
52
|
+
rpop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
53
|
+
lrange: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
|
|
54
|
+
llen: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
55
|
+
lindex: <T = string | null>(key: string, index: number, cb?: Callback<T>) => Promise<T>;
|
|
56
|
+
lset: <T = string>(key: string, index: number, value: string, cb?: Callback<T>) => Promise<T>;
|
|
57
|
+
lrem: <T = number>(key: string, count: number, value: string, cb?: Callback<T>) => Promise<T>;
|
|
58
|
+
sadd: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
59
|
+
srem: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
60
|
+
smembers: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
61
|
+
sismember: <T = number>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
|
|
62
|
+
scard: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
63
|
+
spop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
64
|
+
srandmember: <T = string | string[] | null>(key: string, count?: number | Callback<T>, cb?: Callback<T>) => Promise<T>;
|
|
65
|
+
zadd: <T = number>(key: string, score: number, member: string, options?: ZAddOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
|
|
66
|
+
zrange: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
|
|
67
|
+
zrangeWithScores: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
|
|
68
|
+
zrem: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
69
|
+
zscore: <T = string | null>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
|
|
70
|
+
zrank: <T = number | null>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
|
|
71
|
+
zcard: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
72
|
+
zincrby: <T = string>(key: string, increment: number, member: string, cb?: Callback<T>) => Promise<T>;
|
|
73
|
+
multi: <T = any[]>(commands: {
|
|
74
|
+
command: string;
|
|
75
|
+
args: any[];
|
|
76
|
+
}[], cb?: Callback<T>) => Promise<T>;
|
|
77
|
+
keys: <T = string[]>(pattern: string, cb?: Callback<T>) => Promise<T>;
|
|
78
|
+
scan: <T = [string, string[]]>(cursor: number, options?: ScanOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
|
|
79
|
+
type: <T = string>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
80
|
+
rename: <T = string>(key: string, newKey: string, cb?: Callback<T>) => Promise<T>;
|
|
81
|
+
persist: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
82
|
+
pttl: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
83
|
+
expireat: <T = number>(key: string, timestamp: number, cb?: Callback<T>) => Promise<T>;
|
|
84
|
+
ping: <T = string>(cb?: Callback<T>) => Promise<T>;
|
|
85
|
+
flushdb: <T = string>(cb?: Callback<T>) => Promise<T>;
|
|
86
|
+
dbsize: <T = number>(cb?: Callback<T>) => Promise<T>;
|
|
87
|
+
raw: <T = any>(command: string, args: any[], cb?: Callback<T>) => Promise<T>;
|
|
88
|
+
}
|
|
89
|
+
export declare const redisfx: RedisFX;
|
|
90
|
+
export {};
|
package/Redis.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redisfx = void 0;
|
|
4
|
+
function assert(condition, message) {
|
|
5
|
+
if (!condition)
|
|
6
|
+
throw new TypeError(message);
|
|
7
|
+
}
|
|
8
|
+
const safeArgs = (arg1, arg2, cb) => {
|
|
9
|
+
if (arg2 !== undefined) {
|
|
10
|
+
const arg2Type = typeof arg2;
|
|
11
|
+
if (arg2Type === 'function') {
|
|
12
|
+
cb = arg2;
|
|
13
|
+
arg2 = undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (cb !== undefined)
|
|
17
|
+
assert(typeof cb === 'function', `Callback expected function, received ${typeof cb}`);
|
|
18
|
+
return [arg1, arg2, cb];
|
|
19
|
+
};
|
|
20
|
+
const exp = global.exports['redisfx'];
|
|
21
|
+
const currentResourceName = GetCurrentResourceName();
|
|
22
|
+
function execute(method, ...args) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
exp[method](...args, (result, error) => {
|
|
25
|
+
if (error)
|
|
26
|
+
return reject(error);
|
|
27
|
+
resolve(result);
|
|
28
|
+
}, currentResourceName, true);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.redisfx = {
|
|
32
|
+
isReady() {
|
|
33
|
+
return exp.isReady();
|
|
34
|
+
},
|
|
35
|
+
async awaitConnection() {
|
|
36
|
+
return await exp.awaitConnection();
|
|
37
|
+
},
|
|
38
|
+
ready(callback) {
|
|
39
|
+
setImmediate(async () => {
|
|
40
|
+
while (GetResourceState('redisfx') !== 'started')
|
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, 50, null));
|
|
42
|
+
callback();
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
// String commands
|
|
46
|
+
async get(key, cb) {
|
|
47
|
+
const result = await execute('get', key);
|
|
48
|
+
return cb ? cb(result) : result;
|
|
49
|
+
},
|
|
50
|
+
async set(key, value, options, cb) {
|
|
51
|
+
[options, , cb] = safeArgs(options, cb);
|
|
52
|
+
const result = await execute('set', key, value, options);
|
|
53
|
+
return cb ? cb(result) : result;
|
|
54
|
+
},
|
|
55
|
+
async del(keys, cb) {
|
|
56
|
+
const result = await execute('del', keys);
|
|
57
|
+
return cb ? cb(result) : result;
|
|
58
|
+
},
|
|
59
|
+
async exists(keys, cb) {
|
|
60
|
+
const result = await execute('exists', keys);
|
|
61
|
+
return cb ? cb(result) : result;
|
|
62
|
+
},
|
|
63
|
+
async expire(key, seconds, cb) {
|
|
64
|
+
const result = await execute('expire', key, seconds);
|
|
65
|
+
return cb ? cb(result) : result;
|
|
66
|
+
},
|
|
67
|
+
async ttl(key, cb) {
|
|
68
|
+
const result = await execute('ttl', key);
|
|
69
|
+
return cb ? cb(result) : result;
|
|
70
|
+
},
|
|
71
|
+
async incr(key, cb) {
|
|
72
|
+
const result = await execute('incr', key);
|
|
73
|
+
return cb ? cb(result) : result;
|
|
74
|
+
},
|
|
75
|
+
async incrby(key, increment, cb) {
|
|
76
|
+
const result = await execute('incrby', key, increment);
|
|
77
|
+
return cb ? cb(result) : result;
|
|
78
|
+
},
|
|
79
|
+
async decr(key, cb) {
|
|
80
|
+
const result = await execute('decr', key);
|
|
81
|
+
return cb ? cb(result) : result;
|
|
82
|
+
},
|
|
83
|
+
async decrby(key, decrement, cb) {
|
|
84
|
+
const result = await execute('decrby', key, decrement);
|
|
85
|
+
return cb ? cb(result) : result;
|
|
86
|
+
},
|
|
87
|
+
async mget(keys, cb) {
|
|
88
|
+
const result = await execute('mget', keys);
|
|
89
|
+
return cb ? cb(result) : result;
|
|
90
|
+
},
|
|
91
|
+
async mset(keyValues, cb) {
|
|
92
|
+
const result = await execute('mset', keyValues);
|
|
93
|
+
return cb ? cb(result) : result;
|
|
94
|
+
},
|
|
95
|
+
// Hash commands
|
|
96
|
+
async hget(key, field, cb) {
|
|
97
|
+
const result = await execute('hget', key, field);
|
|
98
|
+
return cb ? cb(result) : result;
|
|
99
|
+
},
|
|
100
|
+
async hset(key, field, value, cb) {
|
|
101
|
+
const result = await execute('hset', key, field, value);
|
|
102
|
+
return cb ? cb(result) : result;
|
|
103
|
+
},
|
|
104
|
+
async hmset(key, fieldValues, cb) {
|
|
105
|
+
const result = await execute('hmset', key, fieldValues);
|
|
106
|
+
return cb ? cb(result) : result;
|
|
107
|
+
},
|
|
108
|
+
async hgetall(key, cb) {
|
|
109
|
+
const result = await execute('hgetall', key);
|
|
110
|
+
return cb ? cb(result) : result;
|
|
111
|
+
},
|
|
112
|
+
async hdel(key, fields, cb) {
|
|
113
|
+
const result = await execute('hdel', key, fields);
|
|
114
|
+
return cb ? cb(result) : result;
|
|
115
|
+
},
|
|
116
|
+
async hincrby(key, field, increment, cb) {
|
|
117
|
+
const result = await execute('hincrby', key, field, increment);
|
|
118
|
+
return cb ? cb(result) : result;
|
|
119
|
+
},
|
|
120
|
+
async hexists(key, field, cb) {
|
|
121
|
+
const result = await execute('hexists', key, field);
|
|
122
|
+
return cb ? cb(result) : result;
|
|
123
|
+
},
|
|
124
|
+
async hkeys(key, cb) {
|
|
125
|
+
const result = await execute('hkeys', key);
|
|
126
|
+
return cb ? cb(result) : result;
|
|
127
|
+
},
|
|
128
|
+
async hvals(key, cb) {
|
|
129
|
+
const result = await execute('hvals', key);
|
|
130
|
+
return cb ? cb(result) : result;
|
|
131
|
+
},
|
|
132
|
+
async hlen(key, cb) {
|
|
133
|
+
const result = await execute('hlen', key);
|
|
134
|
+
return cb ? cb(result) : result;
|
|
135
|
+
},
|
|
136
|
+
// List commands
|
|
137
|
+
async lpush(key, values, cb) {
|
|
138
|
+
const result = await execute('lpush', key, values);
|
|
139
|
+
return cb ? cb(result) : result;
|
|
140
|
+
},
|
|
141
|
+
async rpush(key, values, cb) {
|
|
142
|
+
const result = await execute('rpush', key, values);
|
|
143
|
+
return cb ? cb(result) : result;
|
|
144
|
+
},
|
|
145
|
+
async lpop(key, cb) {
|
|
146
|
+
const result = await execute('lpop', key);
|
|
147
|
+
return cb ? cb(result) : result;
|
|
148
|
+
},
|
|
149
|
+
async rpop(key, cb) {
|
|
150
|
+
const result = await execute('rpop', key);
|
|
151
|
+
return cb ? cb(result) : result;
|
|
152
|
+
},
|
|
153
|
+
async lrange(key, start, stop, cb) {
|
|
154
|
+
const result = await execute('lrange', key, start, stop);
|
|
155
|
+
return cb ? cb(result) : result;
|
|
156
|
+
},
|
|
157
|
+
async llen(key, cb) {
|
|
158
|
+
const result = await execute('llen', key);
|
|
159
|
+
return cb ? cb(result) : result;
|
|
160
|
+
},
|
|
161
|
+
async lindex(key, index, cb) {
|
|
162
|
+
const result = await execute('lindex', key, index);
|
|
163
|
+
return cb ? cb(result) : result;
|
|
164
|
+
},
|
|
165
|
+
async lset(key, index, value, cb) {
|
|
166
|
+
const result = await execute('lset', key, index, value);
|
|
167
|
+
return cb ? cb(result) : result;
|
|
168
|
+
},
|
|
169
|
+
async lrem(key, count, value, cb) {
|
|
170
|
+
const result = await execute('lrem', key, count, value);
|
|
171
|
+
return cb ? cb(result) : result;
|
|
172
|
+
},
|
|
173
|
+
// Set commands
|
|
174
|
+
async sadd(key, members, cb) {
|
|
175
|
+
const result = await execute('sadd', key, members);
|
|
176
|
+
return cb ? cb(result) : result;
|
|
177
|
+
},
|
|
178
|
+
async srem(key, members, cb) {
|
|
179
|
+
const result = await execute('srem', key, members);
|
|
180
|
+
return cb ? cb(result) : result;
|
|
181
|
+
},
|
|
182
|
+
async smembers(key, cb) {
|
|
183
|
+
const result = await execute('smembers', key);
|
|
184
|
+
return cb ? cb(result) : result;
|
|
185
|
+
},
|
|
186
|
+
async sismember(key, member, cb) {
|
|
187
|
+
const result = await execute('sismember', key, member);
|
|
188
|
+
return cb ? cb(result) : result;
|
|
189
|
+
},
|
|
190
|
+
async scard(key, cb) {
|
|
191
|
+
const result = await execute('scard', key);
|
|
192
|
+
return cb ? cb(result) : result;
|
|
193
|
+
},
|
|
194
|
+
async spop(key, cb) {
|
|
195
|
+
const result = await execute('spop', key);
|
|
196
|
+
return cb ? cb(result) : result;
|
|
197
|
+
},
|
|
198
|
+
async srandmember(key, count, cb) {
|
|
199
|
+
[count, , cb] = safeArgs(count, cb);
|
|
200
|
+
const result = count !== undefined ? await execute('srandmember', key, count) : await execute('srandmember', key);
|
|
201
|
+
return cb ? cb(result) : result;
|
|
202
|
+
},
|
|
203
|
+
// Sorted set commands
|
|
204
|
+
async zadd(key, score, member, options, cb) {
|
|
205
|
+
[options, , cb] = safeArgs(options, cb);
|
|
206
|
+
const result = await execute('zadd', key, score, member, options);
|
|
207
|
+
return cb ? cb(result) : result;
|
|
208
|
+
},
|
|
209
|
+
async zrange(key, start, stop, cb) {
|
|
210
|
+
const result = await execute('zrange', key, start, stop);
|
|
211
|
+
return cb ? cb(result) : result;
|
|
212
|
+
},
|
|
213
|
+
async zrangeWithScores(key, start, stop, cb) {
|
|
214
|
+
const result = await execute('zrangeWithScores', key, start, stop);
|
|
215
|
+
return cb ? cb(result) : result;
|
|
216
|
+
},
|
|
217
|
+
async zrem(key, members, cb) {
|
|
218
|
+
const result = await execute('zrem', key, members);
|
|
219
|
+
return cb ? cb(result) : result;
|
|
220
|
+
},
|
|
221
|
+
async zscore(key, member, cb) {
|
|
222
|
+
const result = await execute('zscore', key, member);
|
|
223
|
+
return cb ? cb(result) : result;
|
|
224
|
+
},
|
|
225
|
+
async zrank(key, member, cb) {
|
|
226
|
+
const result = await execute('zrank', key, member);
|
|
227
|
+
return cb ? cb(result) : result;
|
|
228
|
+
},
|
|
229
|
+
async zcard(key, cb) {
|
|
230
|
+
const result = await execute('zcard', key);
|
|
231
|
+
return cb ? cb(result) : result;
|
|
232
|
+
},
|
|
233
|
+
async zincrby(key, increment, member, cb) {
|
|
234
|
+
const result = await execute('zincrby', key, increment, member);
|
|
235
|
+
return cb ? cb(result) : result;
|
|
236
|
+
},
|
|
237
|
+
// Transaction
|
|
238
|
+
async multi(commands, cb) {
|
|
239
|
+
const result = await execute('multi', commands);
|
|
240
|
+
return cb ? cb(result) : result;
|
|
241
|
+
},
|
|
242
|
+
// Key commands
|
|
243
|
+
async keys(pattern, cb) {
|
|
244
|
+
const result = await execute('keys', pattern);
|
|
245
|
+
return cb ? cb(result) : result;
|
|
246
|
+
},
|
|
247
|
+
async scan(cursor, options, cb) {
|
|
248
|
+
[options, , cb] = safeArgs(options, cb);
|
|
249
|
+
const result = await execute('scan', cursor, options);
|
|
250
|
+
return cb ? cb(result) : result;
|
|
251
|
+
},
|
|
252
|
+
async type(key, cb) {
|
|
253
|
+
const result = await execute('type', key);
|
|
254
|
+
return cb ? cb(result) : result;
|
|
255
|
+
},
|
|
256
|
+
async rename(key, newKey, cb) {
|
|
257
|
+
const result = await execute('rename', key, newKey);
|
|
258
|
+
return cb ? cb(result) : result;
|
|
259
|
+
},
|
|
260
|
+
async persist(key, cb) {
|
|
261
|
+
const result = await execute('persist', key);
|
|
262
|
+
return cb ? cb(result) : result;
|
|
263
|
+
},
|
|
264
|
+
async pttl(key, cb) {
|
|
265
|
+
const result = await execute('pttl', key);
|
|
266
|
+
return cb ? cb(result) : result;
|
|
267
|
+
},
|
|
268
|
+
async expireat(key, timestamp, cb) {
|
|
269
|
+
const result = await execute('expireat', key, timestamp);
|
|
270
|
+
return cb ? cb(result) : result;
|
|
271
|
+
},
|
|
272
|
+
// Server commands
|
|
273
|
+
async ping(cb) {
|
|
274
|
+
const result = await execute('ping');
|
|
275
|
+
return cb ? cb(result) : result;
|
|
276
|
+
},
|
|
277
|
+
async flushdb(cb) {
|
|
278
|
+
const result = await execute('flushdb');
|
|
279
|
+
return cb ? cb(result) : result;
|
|
280
|
+
},
|
|
281
|
+
async dbsize(cb) {
|
|
282
|
+
const result = await execute('dbsize');
|
|
283
|
+
return cb ? cb(result) : result;
|
|
284
|
+
},
|
|
285
|
+
// Raw command
|
|
286
|
+
async raw(command, args, cb) {
|
|
287
|
+
const result = await execute('raw', command, args);
|
|
288
|
+
return cb ? cb(result) : result;
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
//# sourceMappingURL=Redis.js.map
|
package/Redis.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Redis.js","sourceRoot":"","sources":["Redis.ts"],"names":[],"mappings":";;;AA6GA,SAAS,MAAM,CAAC,SAAkB,EAAE,OAAe;IACjD,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,IAAS,EAAE,IAAU,EAAE,EAAa,EAAE,EAAE;IACxD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,QA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CAAC,CAAC;QACzD,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,IAAI,CAAC,EAAE;QACX,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,EAAE;QACb,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,cAAc;IACd,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACnD,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;CACF,CAAC"}
|
package/Redis.ts
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
type Callback<T> = (result: T | null) => void;
|
|
2
|
+
|
|
3
|
+
interface SetOptions {
|
|
4
|
+
EX?: number;
|
|
5
|
+
PX?: number;
|
|
6
|
+
EXAT?: number;
|
|
7
|
+
PXAT?: number;
|
|
8
|
+
NX?: boolean;
|
|
9
|
+
XX?: boolean;
|
|
10
|
+
KEEPTTL?: boolean;
|
|
11
|
+
GET?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ZAddOptions {
|
|
15
|
+
NX?: boolean;
|
|
16
|
+
XX?: boolean;
|
|
17
|
+
GT?: boolean;
|
|
18
|
+
LT?: boolean;
|
|
19
|
+
CH?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ScanOptions {
|
|
23
|
+
MATCH?: string;
|
|
24
|
+
COUNT?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface RedisFX {
|
|
28
|
+
// Connection
|
|
29
|
+
isReady: () => boolean;
|
|
30
|
+
awaitConnection: () => Promise<true>;
|
|
31
|
+
ready: (callback: () => void) => void;
|
|
32
|
+
|
|
33
|
+
// String commands
|
|
34
|
+
get: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
35
|
+
set: <T = string | null>(key: string, value: string | number, options?: SetOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
|
|
36
|
+
del: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
37
|
+
exists: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
38
|
+
expire: <T = number>(key: string, seconds: number, cb?: Callback<T>) => Promise<T>;
|
|
39
|
+
ttl: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
40
|
+
incr: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
41
|
+
incrby: <T = number>(key: string, increment: number, cb?: Callback<T>) => Promise<T>;
|
|
42
|
+
decr: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
43
|
+
decrby: <T = number>(key: string, decrement: number, cb?: Callback<T>) => Promise<T>;
|
|
44
|
+
mget: <T = (string | null)[]>(keys: string[], cb?: Callback<T>) => Promise<T>;
|
|
45
|
+
mset: <T = string>(keyValues: Record<string, string | number>, cb?: Callback<T>) => Promise<T>;
|
|
46
|
+
|
|
47
|
+
// Hash commands
|
|
48
|
+
hget: <T = string | null>(key: string, field: string, cb?: Callback<T>) => Promise<T>;
|
|
49
|
+
hset: <T = number>(key: string, field: string, value: string | number, cb?: Callback<T>) => Promise<T>;
|
|
50
|
+
hmset: <T = number>(key: string, fieldValues: Record<string, string | number>, cb?: Callback<T>) => Promise<T>;
|
|
51
|
+
hgetall: <T = Record<string, string>>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
52
|
+
hdel: <T = number>(key: string, fields: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
53
|
+
hincrby: <T = number>(key: string, field: string, increment: number, cb?: Callback<T>) => Promise<T>;
|
|
54
|
+
hexists: <T = number>(key: string, field: string, cb?: Callback<T>) => Promise<T>;
|
|
55
|
+
hkeys: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
56
|
+
hvals: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
57
|
+
hlen: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
58
|
+
|
|
59
|
+
// List commands
|
|
60
|
+
lpush: <T = number>(key: string, values: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
61
|
+
rpush: <T = number>(key: string, values: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
62
|
+
lpop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
63
|
+
rpop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
64
|
+
lrange: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
|
|
65
|
+
llen: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
66
|
+
lindex: <T = string | null>(key: string, index: number, cb?: Callback<T>) => Promise<T>;
|
|
67
|
+
lset: <T = string>(key: string, index: number, value: string, cb?: Callback<T>) => Promise<T>;
|
|
68
|
+
lrem: <T = number>(key: string, count: number, value: string, cb?: Callback<T>) => Promise<T>;
|
|
69
|
+
|
|
70
|
+
// Set commands
|
|
71
|
+
sadd: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
72
|
+
srem: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
73
|
+
smembers: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
74
|
+
sismember: <T = number>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
|
|
75
|
+
scard: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
76
|
+
spop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
77
|
+
srandmember: <T = string | string[] | null>(key: string, count?: number | Callback<T>, cb?: Callback<T>) => Promise<T>;
|
|
78
|
+
|
|
79
|
+
// Sorted set commands
|
|
80
|
+
zadd: <T = number>(key: string, score: number, member: string, options?: ZAddOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
|
|
81
|
+
zrange: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
|
|
82
|
+
zrangeWithScores: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
|
|
83
|
+
zrem: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
|
|
84
|
+
zscore: <T = string | null>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
|
|
85
|
+
zrank: <T = number | null>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
|
|
86
|
+
zcard: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
87
|
+
zincrby: <T = string>(key: string, increment: number, member: string, cb?: Callback<T>) => Promise<T>;
|
|
88
|
+
|
|
89
|
+
// Transaction commands
|
|
90
|
+
multi: <T = any[]>(commands: { command: string; args: any[] }[], cb?: Callback<T>) => Promise<T>;
|
|
91
|
+
|
|
92
|
+
// Key commands
|
|
93
|
+
keys: <T = string[]>(pattern: string, cb?: Callback<T>) => Promise<T>;
|
|
94
|
+
scan: <T = [string, string[]]>(cursor: number, options?: ScanOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
|
|
95
|
+
type: <T = string>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
96
|
+
rename: <T = string>(key: string, newKey: string, cb?: Callback<T>) => Promise<T>;
|
|
97
|
+
persist: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
98
|
+
pttl: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
|
|
99
|
+
expireat: <T = number>(key: string, timestamp: number, cb?: Callback<T>) => Promise<T>;
|
|
100
|
+
|
|
101
|
+
// Server commands
|
|
102
|
+
ping: <T = string>(cb?: Callback<T>) => Promise<T>;
|
|
103
|
+
flushdb: <T = string>(cb?: Callback<T>) => Promise<T>;
|
|
104
|
+
dbsize: <T = number>(cb?: Callback<T>) => Promise<T>;
|
|
105
|
+
|
|
106
|
+
// Raw command
|
|
107
|
+
raw: <T = any>(command: string, args: any[], cb?: Callback<T>) => Promise<T>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function assert(condition: boolean, message: string) {
|
|
111
|
+
if (!condition) throw new TypeError(message);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const safeArgs = (arg1: any, arg2?: any, cb?: Function) => {
|
|
115
|
+
if (arg2 !== undefined) {
|
|
116
|
+
const arg2Type = typeof arg2;
|
|
117
|
+
if (arg2Type === 'function') {
|
|
118
|
+
cb = arg2;
|
|
119
|
+
arg2 = undefined;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (cb !== undefined) assert(typeof cb === 'function', `Callback expected function, received ${typeof cb}`);
|
|
124
|
+
|
|
125
|
+
return [arg1, arg2, cb];
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
declare var global: any;
|
|
129
|
+
const exp = global.exports['redisfx'];
|
|
130
|
+
const currentResourceName = GetCurrentResourceName();
|
|
131
|
+
|
|
132
|
+
function execute(method: string, ...args: any[]) {
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
exp[method](
|
|
135
|
+
...args,
|
|
136
|
+
(result: any, error: any) => {
|
|
137
|
+
if (error) return reject(error);
|
|
138
|
+
resolve(result);
|
|
139
|
+
},
|
|
140
|
+
currentResourceName,
|
|
141
|
+
true
|
|
142
|
+
);
|
|
143
|
+
}) as any;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export const redisfx: RedisFX = {
|
|
147
|
+
isReady() {
|
|
148
|
+
return exp.isReady();
|
|
149
|
+
},
|
|
150
|
+
async awaitConnection() {
|
|
151
|
+
return await exp.awaitConnection();
|
|
152
|
+
},
|
|
153
|
+
ready(callback) {
|
|
154
|
+
setImmediate(async () => {
|
|
155
|
+
while (GetResourceState('redisfx') !== 'started') await new Promise((resolve) => setTimeout(resolve, 50, null));
|
|
156
|
+
callback();
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
// String commands
|
|
161
|
+
async get(key, cb) {
|
|
162
|
+
const result = await execute('get', key);
|
|
163
|
+
return cb ? cb(result) : result;
|
|
164
|
+
},
|
|
165
|
+
async set(key, value, options, cb) {
|
|
166
|
+
[options, , cb] = safeArgs(options, cb);
|
|
167
|
+
const result = await execute('set', key, value, options);
|
|
168
|
+
return cb ? cb(result) : result;
|
|
169
|
+
},
|
|
170
|
+
async del(keys, cb) {
|
|
171
|
+
const result = await execute('del', keys);
|
|
172
|
+
return cb ? cb(result) : result;
|
|
173
|
+
},
|
|
174
|
+
async exists(keys, cb) {
|
|
175
|
+
const result = await execute('exists', keys);
|
|
176
|
+
return cb ? cb(result) : result;
|
|
177
|
+
},
|
|
178
|
+
async expire(key, seconds, cb) {
|
|
179
|
+
const result = await execute('expire', key, seconds);
|
|
180
|
+
return cb ? cb(result) : result;
|
|
181
|
+
},
|
|
182
|
+
async ttl(key, cb) {
|
|
183
|
+
const result = await execute('ttl', key);
|
|
184
|
+
return cb ? cb(result) : result;
|
|
185
|
+
},
|
|
186
|
+
async incr(key, cb) {
|
|
187
|
+
const result = await execute('incr', key);
|
|
188
|
+
return cb ? cb(result) : result;
|
|
189
|
+
},
|
|
190
|
+
async incrby(key, increment, cb) {
|
|
191
|
+
const result = await execute('incrby', key, increment);
|
|
192
|
+
return cb ? cb(result) : result;
|
|
193
|
+
},
|
|
194
|
+
async decr(key, cb) {
|
|
195
|
+
const result = await execute('decr', key);
|
|
196
|
+
return cb ? cb(result) : result;
|
|
197
|
+
},
|
|
198
|
+
async decrby(key, decrement, cb) {
|
|
199
|
+
const result = await execute('decrby', key, decrement);
|
|
200
|
+
return cb ? cb(result) : result;
|
|
201
|
+
},
|
|
202
|
+
async mget(keys, cb) {
|
|
203
|
+
const result = await execute('mget', keys);
|
|
204
|
+
return cb ? cb(result) : result;
|
|
205
|
+
},
|
|
206
|
+
async mset(keyValues, cb) {
|
|
207
|
+
const result = await execute('mset', keyValues);
|
|
208
|
+
return cb ? cb(result) : result;
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
// Hash commands
|
|
212
|
+
async hget(key, field, cb) {
|
|
213
|
+
const result = await execute('hget', key, field);
|
|
214
|
+
return cb ? cb(result) : result;
|
|
215
|
+
},
|
|
216
|
+
async hset(key, field, value, cb) {
|
|
217
|
+
const result = await execute('hset', key, field, value);
|
|
218
|
+
return cb ? cb(result) : result;
|
|
219
|
+
},
|
|
220
|
+
async hmset(key, fieldValues, cb) {
|
|
221
|
+
const result = await execute('hmset', key, fieldValues);
|
|
222
|
+
return cb ? cb(result) : result;
|
|
223
|
+
},
|
|
224
|
+
async hgetall(key, cb) {
|
|
225
|
+
const result = await execute('hgetall', key);
|
|
226
|
+
return cb ? cb(result) : result;
|
|
227
|
+
},
|
|
228
|
+
async hdel(key, fields, cb) {
|
|
229
|
+
const result = await execute('hdel', key, fields);
|
|
230
|
+
return cb ? cb(result) : result;
|
|
231
|
+
},
|
|
232
|
+
async hincrby(key, field, increment, cb) {
|
|
233
|
+
const result = await execute('hincrby', key, field, increment);
|
|
234
|
+
return cb ? cb(result) : result;
|
|
235
|
+
},
|
|
236
|
+
async hexists(key, field, cb) {
|
|
237
|
+
const result = await execute('hexists', key, field);
|
|
238
|
+
return cb ? cb(result) : result;
|
|
239
|
+
},
|
|
240
|
+
async hkeys(key, cb) {
|
|
241
|
+
const result = await execute('hkeys', key);
|
|
242
|
+
return cb ? cb(result) : result;
|
|
243
|
+
},
|
|
244
|
+
async hvals(key, cb) {
|
|
245
|
+
const result = await execute('hvals', key);
|
|
246
|
+
return cb ? cb(result) : result;
|
|
247
|
+
},
|
|
248
|
+
async hlen(key, cb) {
|
|
249
|
+
const result = await execute('hlen', key);
|
|
250
|
+
return cb ? cb(result) : result;
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
// List commands
|
|
254
|
+
async lpush(key, values, cb) {
|
|
255
|
+
const result = await execute('lpush', key, values);
|
|
256
|
+
return cb ? cb(result) : result;
|
|
257
|
+
},
|
|
258
|
+
async rpush(key, values, cb) {
|
|
259
|
+
const result = await execute('rpush', key, values);
|
|
260
|
+
return cb ? cb(result) : result;
|
|
261
|
+
},
|
|
262
|
+
async lpop(key, cb) {
|
|
263
|
+
const result = await execute('lpop', key);
|
|
264
|
+
return cb ? cb(result) : result;
|
|
265
|
+
},
|
|
266
|
+
async rpop(key, cb) {
|
|
267
|
+
const result = await execute('rpop', key);
|
|
268
|
+
return cb ? cb(result) : result;
|
|
269
|
+
},
|
|
270
|
+
async lrange(key, start, stop, cb) {
|
|
271
|
+
const result = await execute('lrange', key, start, stop);
|
|
272
|
+
return cb ? cb(result) : result;
|
|
273
|
+
},
|
|
274
|
+
async llen(key, cb) {
|
|
275
|
+
const result = await execute('llen', key);
|
|
276
|
+
return cb ? cb(result) : result;
|
|
277
|
+
},
|
|
278
|
+
async lindex(key, index, cb) {
|
|
279
|
+
const result = await execute('lindex', key, index);
|
|
280
|
+
return cb ? cb(result) : result;
|
|
281
|
+
},
|
|
282
|
+
async lset(key, index, value, cb) {
|
|
283
|
+
const result = await execute('lset', key, index, value);
|
|
284
|
+
return cb ? cb(result) : result;
|
|
285
|
+
},
|
|
286
|
+
async lrem(key, count, value, cb) {
|
|
287
|
+
const result = await execute('lrem', key, count, value);
|
|
288
|
+
return cb ? cb(result) : result;
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
// Set commands
|
|
292
|
+
async sadd(key, members, cb) {
|
|
293
|
+
const result = await execute('sadd', key, members);
|
|
294
|
+
return cb ? cb(result) : result;
|
|
295
|
+
},
|
|
296
|
+
async srem(key, members, cb) {
|
|
297
|
+
const result = await execute('srem', key, members);
|
|
298
|
+
return cb ? cb(result) : result;
|
|
299
|
+
},
|
|
300
|
+
async smembers(key, cb) {
|
|
301
|
+
const result = await execute('smembers', key);
|
|
302
|
+
return cb ? cb(result) : result;
|
|
303
|
+
},
|
|
304
|
+
async sismember(key, member, cb) {
|
|
305
|
+
const result = await execute('sismember', key, member);
|
|
306
|
+
return cb ? cb(result) : result;
|
|
307
|
+
},
|
|
308
|
+
async scard(key, cb) {
|
|
309
|
+
const result = await execute('scard', key);
|
|
310
|
+
return cb ? cb(result) : result;
|
|
311
|
+
},
|
|
312
|
+
async spop(key, cb) {
|
|
313
|
+
const result = await execute('spop', key);
|
|
314
|
+
return cb ? cb(result) : result;
|
|
315
|
+
},
|
|
316
|
+
async srandmember(key, count, cb) {
|
|
317
|
+
[count, , cb] = safeArgs(count, cb);
|
|
318
|
+
const result = count !== undefined ? await execute('srandmember', key, count) : await execute('srandmember', key);
|
|
319
|
+
return cb ? cb(result) : result;
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
// Sorted set commands
|
|
323
|
+
async zadd(key, score, member, options, cb) {
|
|
324
|
+
[options, , cb] = safeArgs(options, cb);
|
|
325
|
+
const result = await execute('zadd', key, score, member, options);
|
|
326
|
+
return cb ? cb(result) : result;
|
|
327
|
+
},
|
|
328
|
+
async zrange(key, start, stop, cb) {
|
|
329
|
+
const result = await execute('zrange', key, start, stop);
|
|
330
|
+
return cb ? cb(result) : result;
|
|
331
|
+
},
|
|
332
|
+
async zrangeWithScores(key, start, stop, cb) {
|
|
333
|
+
const result = await execute('zrangeWithScores', key, start, stop);
|
|
334
|
+
return cb ? cb(result) : result;
|
|
335
|
+
},
|
|
336
|
+
async zrem(key, members, cb) {
|
|
337
|
+
const result = await execute('zrem', key, members);
|
|
338
|
+
return cb ? cb(result) : result;
|
|
339
|
+
},
|
|
340
|
+
async zscore(key, member, cb) {
|
|
341
|
+
const result = await execute('zscore', key, member);
|
|
342
|
+
return cb ? cb(result) : result;
|
|
343
|
+
},
|
|
344
|
+
async zrank(key, member, cb) {
|
|
345
|
+
const result = await execute('zrank', key, member);
|
|
346
|
+
return cb ? cb(result) : result;
|
|
347
|
+
},
|
|
348
|
+
async zcard(key, cb) {
|
|
349
|
+
const result = await execute('zcard', key);
|
|
350
|
+
return cb ? cb(result) : result;
|
|
351
|
+
},
|
|
352
|
+
async zincrby(key, increment, member, cb) {
|
|
353
|
+
const result = await execute('zincrby', key, increment, member);
|
|
354
|
+
return cb ? cb(result) : result;
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
// Transaction
|
|
358
|
+
async multi(commands, cb) {
|
|
359
|
+
const result = await execute('multi', commands);
|
|
360
|
+
return cb ? cb(result) : result;
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
// Key commands
|
|
364
|
+
async keys(pattern, cb) {
|
|
365
|
+
const result = await execute('keys', pattern);
|
|
366
|
+
return cb ? cb(result) : result;
|
|
367
|
+
},
|
|
368
|
+
async scan(cursor, options, cb) {
|
|
369
|
+
[options, , cb] = safeArgs(options, cb);
|
|
370
|
+
const result = await execute('scan', cursor, options);
|
|
371
|
+
return cb ? cb(result) : result;
|
|
372
|
+
},
|
|
373
|
+
async type(key, cb) {
|
|
374
|
+
const result = await execute('type', key);
|
|
375
|
+
return cb ? cb(result) : result;
|
|
376
|
+
},
|
|
377
|
+
async rename(key, newKey, cb) {
|
|
378
|
+
const result = await execute('rename', key, newKey);
|
|
379
|
+
return cb ? cb(result) : result;
|
|
380
|
+
},
|
|
381
|
+
async persist(key, cb) {
|
|
382
|
+
const result = await execute('persist', key);
|
|
383
|
+
return cb ? cb(result) : result;
|
|
384
|
+
},
|
|
385
|
+
async pttl(key, cb) {
|
|
386
|
+
const result = await execute('pttl', key);
|
|
387
|
+
return cb ? cb(result) : result;
|
|
388
|
+
},
|
|
389
|
+
async expireat(key, timestamp, cb) {
|
|
390
|
+
const result = await execute('expireat', key, timestamp);
|
|
391
|
+
return cb ? cb(result) : result;
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
// Server commands
|
|
395
|
+
async ping(cb) {
|
|
396
|
+
const result = await execute('ping');
|
|
397
|
+
return cb ? cb(result) : result;
|
|
398
|
+
},
|
|
399
|
+
async flushdb(cb) {
|
|
400
|
+
const result = await execute('flushdb');
|
|
401
|
+
return cb ? cb(result) : result;
|
|
402
|
+
},
|
|
403
|
+
async dbsize(cb) {
|
|
404
|
+
const result = await execute('dbsize');
|
|
405
|
+
return cb ? cb(result) : result;
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
// Raw command
|
|
409
|
+
async raw(command, args, cb) {
|
|
410
|
+
const result = await execute('raw', command, args);
|
|
411
|
+
return cb ? cb(result) : result;
|
|
412
|
+
},
|
|
413
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@m3ftwz/redisfx",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Exports wrapper for redisfx",
|
|
5
|
+
"types": "Redis.d.ts",
|
|
6
|
+
"main": "Redis.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prepublish": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/m3ftwz/redisfx.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"fivem",
|
|
16
|
+
"redisfx",
|
|
17
|
+
"redis"
|
|
18
|
+
],
|
|
19
|
+
"author": "m3ftwz",
|
|
20
|
+
"license": "LGPL-3.0",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/m3ftwz/redisfx/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/m3ftwz/redisfx#readme"
|
|
25
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"outDir": ".",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"module": "CommonJS",
|
|
7
|
+
"types": ["@citizenfx/server"],
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"target": "ESNext",
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
"lib": ["ESNext"],
|
|
13
|
+
"noEmitOnError": false,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"esModuleInterop": true,
|
|
16
|
+
"rootDir": ".",
|
|
17
|
+
"moduleResolution": "node",
|
|
18
|
+
"experimentalDecorators": true,
|
|
19
|
+
"noImplicitAny": false,
|
|
20
|
+
"noEmit": false
|
|
21
|
+
},
|
|
22
|
+
"include": ["Redis.ts"],
|
|
23
|
+
"exclude": ["**/node_modules"]
|
|
24
|
+
}
|