1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/doctests/string-set-get-example.js
Igor Malinovskiy caaca48ca1 Add Redis.io code examples
- Add set & get example
- Use bash script to test doc tests
- Add package.json to doctests
- Add search-quickstart
2023-05-17 12:17:34 +02:00

26 lines
515 B
JavaScript

// EXAMPLE: set_and_get
// REMOVE_START
import assert from "assert";
// REMOVE_END
// HIDE_START
import { createClient } from 'redis';
const client = createClient();
client.on('error', err => console.log('Redis Client Error', err));
await client.connect();
// HIDE_END
await client.set('bike:1', 'Process 134');
const value = await client.get('bike:1');
console.log(value);
// returns 'Process 134'
//REMOVE_START
assert.equal(value, 'Process 134');
//REMOVE_END
// HIDE_START
await client.quit();
// HIDE_END