Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC-2848 added doc code sample for Cuckoo filter #284

Merged
merged 2 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 62 additions & 0 deletions tests/Doc/Cuckoo_tutorial.cs
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