1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

DOC-3933: final 8 tabbed code examples (#2784)

This commit is contained in:
David Dougherty
2024-07-03 12:29:13 -07:00
committed by GitHub
parent e7347f8a51
commit 0f3d0f3d1f
8 changed files with 543 additions and 0 deletions

46
doctests/dt-bloom.js Normal file
View File

@@ -0,0 +1,46 @@
// EXAMPLE: bf_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 bloom
const res1 = await client.bf.reserve('bikes:models', 0.01, 1000);
console.log(res1); // >>> OK
const res2 = await client.bf.add('bikes:models', 'Smoky Mountain Striker');
console.log(res2); // >>> true
const res3 = await client.bf.exists('bikes:models', 'Smoky Mountain Striker');
console.log(res3); // >>> true
const res4 = await client.bf.mAdd('bikes:models', [
'Rocky Mountain Racer',
'Cloudy City Cruiser',
'Windy City Wippet'
]);
console.log(res4); // >>> [true, true, true]
const res5 = await client.bf.mExists('bikes:models', [
'Rocky Mountain Racer',
'Cloudy City Cruiser',
'Windy City Wippet'
]);
console.log(res5); // >>> [true, true, true]
// STEP_END
// REMOVE_START
assert.equal(res1, 'OK')
assert.equal(res2, true)
assert.equal(res3, true)
assert.deepEqual(res4, [true, true, true])
assert.deepEqual(res5, [true, true, true])
await client.quit();
// REMOVE_END