You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
DOC-3914: re-issue TCE PRs previously issued by justincastilla (#2781)
This commit is contained in:
39
doctests/dt-bitmap.js
Normal file
39
doctests/dt-bitmap.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// EXAMPLE: bitmap_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 ping
|
||||
const res1 = await client.setBit("pings:2024-01-01-00:00", 123, 1)
|
||||
console.log(res1) // >>> 0
|
||||
|
||||
const res2 = await client.getBit("pings:2024-01-01-00:00", 123)
|
||||
console.log(res2) // >>> 1
|
||||
|
||||
const res3 = await client.getBit("pings:2024-01-01-00:00", 456)
|
||||
console.log(res3) // >>> 0
|
||||
// STEP_END
|
||||
|
||||
// REMOVE_START
|
||||
assert.equal(res1, 0)
|
||||
// REMOVE_END
|
||||
|
||||
// STEP_START bitcount
|
||||
// HIDE_START
|
||||
await client.setBit("pings:2024-01-01-00:00", 123, 1)
|
||||
// HIDE_END
|
||||
const res4 = await client.bitCount("pings:2024-01-01-00:00")
|
||||
console.log(res4) // >>> 1
|
||||
// STEP_END
|
||||
// REMOVE_START
|
||||
assert.equal(res4, 1)
|
||||
await client.quit();
|
||||
// REMOVE_END
|
Reference in New Issue
Block a user