1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Updates examples. (#2219)

* Updates examples.

* Added command link for hset.
This commit is contained in:
Simon Prickett
2022-08-15 13:39:28 +01:00
committed by GitHub
parent 60ad6aab0b
commit f3462abf33
19 changed files with 972 additions and 1019 deletions

View File

@@ -6,27 +6,25 @@
import { createClient, commandOptions } from 'redis';
async function blockingListPop() {
const client = createClient();
const client = createClient();
await client.connect();
await client.connect();
const keyName = 'keyName';
const keyName = 'keyName';
const blpopPromise = client.blPop(
commandOptions({ isolated: true }),
keyName,
0
);
const blpopPromise = client.blPop(
commandOptions({ isolated: true }),
keyName,
0
);
await client.lPush(keyName, 'value');
await client.lPush(keyName, 'value');
await blpopPromise;
const listItem = await blpopPromise;
console.log('blpopPromise resolved');
console.log(keyName);
console.log('blpopPromise resolved');
// listItem will be:
// {"key":"keyName","element":"value"}
console.log(`listItem is '${JSON.stringify(listItem)}'`);
await client.quit();
}
blockingListPop();
await client.quit();