-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOC-2848 added doc code sample for Cuckoo filter (#284)
- Loading branch information
1 parent
32bfbce
commit ecba417
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// EXAMPLE: cuckoo_tutorial | ||
// HIDE_START | ||
|
||
using NRedisStack.RedisStackCommands; | ||
using NRedisStack.Tests; | ||
using StackExchange.Redis; | ||
|
||
// HIDE_END | ||
|
||
// REMOVE_START | ||
namespace Doc; | ||
[Collection("DocsTests")] | ||
// REMOVE_END | ||
|
||
// HIDE_START | ||
public class Cuckoo_tutorial | ||
{ | ||
|
||
[SkipIfRedis(Is.OSSCluster)] | ||
public void run() | ||
{ | ||
var muxer = ConnectionMultiplexer.Connect("localhost:6379"); | ||
var db = muxer.GetDatabase(); | ||
//REMOVE_START | ||
// Clear any keys here before using them in tests. | ||
db.KeyDelete("bikes:models"); | ||
//REMOVE_END | ||
// HIDE_END | ||
|
||
|
||
// STEP_START cuckoo | ||
bool res1 = db.CF().Reserve("bikes:models", 1000000); | ||
Console.WriteLine(res1); // >>> True | ||
|
||
bool res2 = db.CF().Add("bikes:models", "Smoky Mountain Striker"); | ||
Console.WriteLine(res2); // >>> True | ||
|
||
bool res3 = db.CF().Exists("bikes:models", "Smoky Mountain Striker"); | ||
Console.WriteLine(res3); // >>> True | ||
|
||
bool res4 = db.CF().Exists("bikes:models", "Terrible Bike Name"); | ||
Console.WriteLine(res4); // >>> False | ||
|
||
bool res5 = db.CF().Del("bikes:models", "Smoky Mountain Striker"); | ||
Console.WriteLine(res5); // >>> True | ||
// STEP_END | ||
|
||
// Tests for 'cuckoo' step. | ||
// REMOVE_START | ||
Assert.True(res1); | ||
Assert.True(res2); | ||
Assert.True(res3); | ||
Assert.False(res4); | ||
Assert.True(res5); | ||
// REMOVE_END | ||
|
||
|
||
// HIDE_START | ||
} | ||
} | ||
// HIDE_END | ||
|