Skip to content

Commit 4086d85

Browse files
committed
Adds command-with-modifiers example. (redis#1688)
1 parent dec5048 commit 4086d85

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

examples/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
This folder contains example scripts showing how to use Node Redis in different scenarios.
44

5-
| File Name | Description |
6-
|--------------------------|--------------------------------------|
7-
| `connect-as-acl-user.js` | Connect to Redis 6 using an ACL user |
5+
| File Name | Description |
6+
|-----------------------------|---------------------------------------------------------------------|
7+
| `connect-as-acl-user.js` | Connect to Redis 6 using an ACL user |
8+
| `command-with-modifiers.js` | Define a script that allows to run a command with several modifiers |
89

910
## Contributing
1011

examples/command-with-modifiers.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Define a custom script that shows example of SET command
2+
// with several modifiers.
3+
4+
import { createClient } from 'redis';
5+
6+
async function commandWithModifiers() {
7+
const client = createClient();
8+
9+
await client.connect();
10+
11+
await client.set('mykey', 'myvalue', {
12+
EX: 60,
13+
});
14+
15+
const value = await client.get('mykey');
16+
17+
await client.set('mykey', 'newvalue', {
18+
EX: 60
19+
});
20+
21+
const value = await client.get('mykey');
22+
23+
await client.quit();
24+
}
25+
26+
commandWithModifiers();
27+

0 commit comments

Comments
 (0)