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

Added Java code snippets for cuckoo filters #3679

Merged
merged 3 commits into from
Jan 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/test/java/io/redis/examples/CuckooFilterExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// EXAMPLE: cuckoo_tutorial

// HIDE_START
package io.redis.examples;

import org.junit.Assert;
import org.junit.Test;
import redis.clients.jedis.UnifiedJedis;

public class CuckooFilterExample {
@Test
public void run(){
UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379");
// HIDE_END

// REMOVE_START
jedis.del("bikes:models");
// REMOVE_END

sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
String res1 = jedis.cfReserve("bikes:models", 1000000);
System.out.println(res1); // >>> OK

boolean res2 = jedis.cfAdd("bikes:models", "Smoky Mountain Striker");
System.out.println(res2); // >>> True

boolean res3 = jedis.cfExists("bikes:models", "Smoky Mountain Striker");
System.out.println(res3); // >>> True

boolean res4 = jedis.cfExists("bikes:models", "Terrible Bike Name");
System.out.println(res4); // >>> False

boolean res5 = jedis.cfDel("bikes:models", "Smoky Mountain Striker");
System.out.println(res5); // >>> True
// STEP_END

// REMOVE_START
Assert.assertEquals(res1,"OK");
Assert.assertTrue(res5);
// REMOVE_END
}
}
Loading