Skip to content

Commit c4d14aa

Browse files
committed
fix imports according to the new v5 exports
1 parent ead1054 commit c4d14aa

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

docs/programmability.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,22 @@ FUNCTION LOAD "#!lua name=library\nredis.register_function{function_name='add',
2525
Load the prior redis function on the _redis server_ before running the example below.
2626

2727
```typescript
28-
import { createClient } from 'redis';
28+
import { CommandParser } from '@redis/client/lib/client/parser';
29+
import { NumberReply } from '@redis/client/lib/RESP/types';
30+
import { createClient, RedisArgument } from 'redis';
2931

3032
const client = createClient({
3133
functions: {
3234
library: {
3335
add: {
3436
NUMBER_OF_KEYS: 1,
35-
FIRST_KEY_INDEX: 1,
36-
parseCommand(parser: CommandParser, key: RedisArgument, toAdd: RedisArgument) {
37-
parser.pushKey(key);
38-
parser.push(toAdd);
37+
parseCommand(
38+
parser: CommandParser,
39+
key: RedisArgument,
40+
toAdd: RedisArgument
41+
) {
42+
parser.pushKey(key)
43+
parser.push(toAdd)
3944
},
4045
transformReply: undefined as unknown as () => NumberReply
4146
}
@@ -44,35 +49,39 @@ const client = createClient({
4449
});
4550

4651
await client.connect();
47-
4852
await client.set('key', '1');
49-
await client.library.add('key', 2); // 3
53+
await client.library.add('key', '2'); // 3
5054
```
5155

5256
## [Lua Scripts](https://redis.io/docs/manual/programmability/eval-intro/)
5357

5458
The following is an end-to-end example of the prior concept.
5559

5660
```typescript
57-
import { createClient, defineScript, NumberReply } from 'redis';
61+
import { CommandParser } from '@redis/client/lib/client/parser';
62+
import { NumberReply } from '@redis/client/lib/RESP/types';
63+
import { createClient, defineScript, RedisArgument } from 'redis';
5864

5965
const client = createClient({
6066
scripts: {
6167
add: defineScript({
6268
SCRIPT: 'return redis.call("GET", KEYS[1]) + ARGV[1];',
6369
NUMBER_OF_KEYS: 1,
6470
FIRST_KEY_INDEX: 1,
65-
parseCommand(parser: CommandParser, key: RedisArgument, toAdd: RedisArgument) {
66-
parser.pushKey(key);
67-
parser.push(toAdd);
71+
parseCommand(
72+
parser: CommandParser,
73+
key: RedisArgument,
74+
toAdd: RedisArgument
75+
) {
76+
parser.pushKey(key)
77+
parser.push(toAdd)
6878
},
6979
transformReply: undefined as unknown as () => NumberReply
7080
})
7181
}
7282
});
7383

7484
await client.connect();
75-
7685
await client.set('key', '1');
77-
await client.add('key', 2); // 3
86+
await client.add('key', '2'); // 3
7887
```

0 commit comments

Comments
 (0)