You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
DOC-3933: final 8 tabbed code examples (#2784)
This commit is contained in:
38
doctests/dt-hll.js
Normal file
38
doctests/dt-hll.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// EXAMPLE: hll_tutorial
|
||||
// HIDE_START
|
||||
import assert from 'assert';
|
||||
import { createClient } from 'redis';
|
||||
|
||||
const client = createClient();
|
||||
await client.connect();
|
||||
// HIDE_END
|
||||
|
||||
// REMOVE_START
|
||||
await client.flushDb();
|
||||
// REMOVE_END
|
||||
|
||||
// STEP_START pfadd
|
||||
const res1 = await client.pfAdd('bikes', ['Hyperion', 'Deimos', 'Phoebe', 'Quaoar']);
|
||||
console.log(res1); // >>> true
|
||||
|
||||
const res2 = await client.pfCount('bikes');
|
||||
console.log(res2); // >>> 4
|
||||
|
||||
const res3 = await client.pfAdd('commuter_bikes', ['Salacia', 'Mimas', 'Quaoar']);
|
||||
console.log(res3); // >>> true
|
||||
|
||||
const res4 = await client.pfMerge('all_bikes', ['bikes', 'commuter_bikes']);
|
||||
console.log(res4); // >>> OK
|
||||
|
||||
const res5 = await client.pfCount('all_bikes');
|
||||
console.log(res5); // >>> 6
|
||||
// STEP_END
|
||||
|
||||
// REMOVE_START
|
||||
assert.equal(res1, true)
|
||||
assert.equal(res2, 4)
|
||||
assert.equal(res3, true)
|
||||
assert.equal(res4, 'OK')
|
||||
assert.equal(res5, 6)
|
||||
await client.quit();
|
||||
// REMOVE_END
|
Reference in New Issue
Block a user