Skip to content

Commit 11c6c24

Browse files
authored
Add support for redis functions (#2020)
* fix #1906 - implement BITFIELD_RO * initial support for redis functions * fix test utils * redis functions commands and tests * upgrade deps * fix "Property 'uninstall' does not exist on type 'SinonFakeTimers'" * upgrade dockers version * Merge branch 'master' of github.com:redis/node-redis into functions * fix FUNCTION LIST WITHCODE and FUNCTION STATS * upgrade deps * set minimum version for FCALL and FCALL_RO * fix FUNCTION LOAD * FUNCTION LOAD * fix FUNCTION LOAD & FUNCTION LIST & FUNCTION LOAD WITHCODE * fix FUNCTION_LIST_WITHCODE test
1 parent 23b6513 commit 11c6c24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1408
-326
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
node-version: ['12', '14', '16']
20-
redis-version: ['5', '6.0', '6.2', '7.0-rc2']
20+
redis-version: ['5', '6.0', '6.2', '7.0-rc3']
2121
steps:
2222
- uses: actions/checkout@v2.3.4
2323
with:

index.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
RedisModules,
3+
RedisFunctions,
34
RedisScripts,
45
createClient as _createClient,
56
RedisClientOptions,
@@ -33,12 +34,17 @@ export type RedisDefaultModules = typeof modules;
3334

3435
export type RedisClientType<
3536
M extends RedisModules = RedisDefaultModules,
37+
F extends RedisFunctions = Record<string, never>,
3638
S extends RedisScripts = Record<string, never>
37-
> = _RedisClientType<M, S>;
39+
> = _RedisClientType<M, F, S>;
3840

39-
export function createClient<M extends RedisModules, S extends RedisScripts>(
40-
options?: RedisClientOptions<M, S>
41-
): _RedisClientType<RedisDefaultModules & M, S> {
41+
export function createClient<
42+
M extends RedisModules,
43+
F extends RedisFunctions,
44+
S extends RedisScripts
45+
>(
46+
options?: RedisClientOptions<M, F, S>
47+
): _RedisClientType<RedisDefaultModules & M, F, S> {
4248
return _createClient({
4349
...options,
4450
modules: {
@@ -50,12 +56,17 @@ export function createClient<M extends RedisModules, S extends RedisScripts>(
5056

5157
export type RedisClusterType<
5258
M extends RedisModules = RedisDefaultModules,
59+
F extends RedisFunctions = Record<string, never>,
5360
S extends RedisScripts = Record<string, never>
54-
> = _RedisClusterType<M, S>;
61+
> = _RedisClusterType<M, F, S>;
5562

56-
export function createCluster<M extends RedisModules, S extends RedisScripts>(
57-
options: RedisClusterOptions<M, S>
58-
): RedisClusterType<RedisDefaultModules & M, S> {
63+
export function createCluster<
64+
M extends RedisModules,
65+
F extends RedisFunctions,
66+
S extends RedisScripts
67+
>(
68+
options: RedisClusterOptions<M, F, S>
69+
): RedisClusterType<RedisDefaultModules & M, F, S> {
5970
return _createCluster({
6071
...options,
6172
modules: {

package-lock.json

Lines changed: 34 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import RedisCluster from './lib/cluster';
33

44
export { RedisClientType, RedisClientOptions } from './lib/client';
55

6-
export { RedisModules, RedisScripts } from './lib/commands';
6+
export { RedisModules, RedisFunctions, RedisScripts } from './lib/commands';
77

88
export const createClient = RedisClient.create;
99

packages/client/lib/client/commands.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ import * as ECHO from '../commands/ECHO';
6262
import * as FAILOVER from '../commands/FAILOVER';
6363
import * as FLUSHALL from '../commands/FLUSHALL';
6464
import * as FLUSHDB from '../commands/FLUSHDB';
65+
import * as FUNCTION_DELETE from '../commands/FUNCTION_DELETE';
66+
import * as FUNCTION_DUMP from '../commands/FUNCTION_DUMP';
67+
import * as FUNCTION_FLUSH from '../commands/FUNCTION_FLUSH';
68+
import * as FUNCTION_KILL from '../commands/FUNCTION_KILL';
69+
import * as FUNCTION_LIST_WITHCODE from '../commands/FUNCTION_LIST_WITHCODE';
70+
import * as FUNCTION_LIST from '../commands/FUNCTION_LIST';
71+
import * as FUNCTION_LOAD from '../commands/FUNCTION_LOAD';
72+
import * as FUNCTION_RESTORE from '../commands/FUNCTION_RESTORE';
73+
import * as FUNCTION_STATS from '../commands/FUNCTION_STATS';
6574
import * as HELLO from '../commands/HELLO';
6675
import * as INFO from '../commands/INFO';
6776
import * as KEYS from '../commands/KEYS';
@@ -228,6 +237,24 @@ export default {
228237
flushAll: FLUSHALL,
229238
FLUSHDB,
230239
flushDb: FLUSHDB,
240+
FUNCTION_DELETE,
241+
functionDelete: FUNCTION_DELETE,
242+
FUNCTION_DUMP,
243+
functionDump: FUNCTION_DUMP,
244+
FUNCTION_FLUSH,
245+
functionFlush: FUNCTION_FLUSH,
246+
FUNCTION_KILL,
247+
functionKill: FUNCTION_KILL,
248+
FUNCTION_LIST_WITHCODE,
249+
functionListWithCode: FUNCTION_LIST_WITHCODE,
250+
FUNCTION_LIST,
251+
functionList: FUNCTION_LIST,
252+
FUNCTION_LOAD,
253+
functionLoad: FUNCTION_LOAD,
254+
FUNCTION_RESTORE,
255+
functionRestore: FUNCTION_RESTORE,
256+
FUNCTION_STATS,
257+
functionStats: FUNCTION_STATS,
231258
HELLO,
232259
hello: HELLO,
233260
INFO,

0 commit comments

Comments
 (0)