From 9f810c2f858fa37e1f3bbbab1b4280644d82dc48 Mon Sep 17 00:00:00 2001 From: David Dougherty Date: Thu, 26 Sep 2024 04:21:19 -0700 Subject: [PATCH] Add back accidentally deleted doctests file (#2821) * Add back accidentally deleted doctest file * Update string-set-get-example.js --- doctests/string-set-get-example.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 doctests/string-set-get-example.js diff --git a/doctests/string-set-get-example.js b/doctests/string-set-get-example.js new file mode 100644 index 0000000000..9d74c15e05 --- /dev/null +++ b/doctests/string-set-get-example.js @@ -0,0 +1,27 @@ +// 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