1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-01 16:46:54 +03:00
Files
node-redis/doctests/string-set-get-example.js
David Dougherty 9f810c2f85 Add back accidentally deleted doctests file (#2821)
* Add back accidentally deleted doctest file

* Update string-set-get-example.js
2024-09-26 14:21:19 +03:00

28 lines
570 B
JavaScript

// EXAMPLE: set_and_get
// REMOVE_START
import assert from "node: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().catch(console.error);
// 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');
await client.del('bike:1');
//REMOVE_END
// HIDE_START
await client.quit();
// HIDE_END