From 6839265e503ed19ee4ae91e59145db4d60250598 Mon Sep 17 00:00:00 2001 From: Ranjeet Singh Date: Tue, 9 Jan 2024 19:58:56 +0530 Subject: [PATCH 1/3] Add CuckooFilterExample --- .../redis/examples/CuckooFilterExample.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/test/java/io/redis/examples/CuckooFilterExample.java diff --git a/src/test/java/io/redis/examples/CuckooFilterExample.java b/src/test/java/io/redis/examples/CuckooFilterExample.java new file mode 100644 index 0000000000..64d747735b --- /dev/null +++ b/src/test/java/io/redis/examples/CuckooFilterExample.java @@ -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 + + 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 + } +} From 7a8bf3c1ae19238f957d61b403709265af10c179 Mon Sep 17 00:00:00 2001 From: Ranjeet Singh Date: Tue, 9 Jan 2024 20:11:13 +0530 Subject: [PATCH 2/3] Add step start comment --- src/test/java/io/redis/examples/CuckooFilterExample.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/io/redis/examples/CuckooFilterExample.java b/src/test/java/io/redis/examples/CuckooFilterExample.java index 64d747735b..91a79bbf2e 100644 --- a/src/test/java/io/redis/examples/CuckooFilterExample.java +++ b/src/test/java/io/redis/examples/CuckooFilterExample.java @@ -17,6 +17,7 @@ public void run(){ jedis.del("bikes:models"); // REMOVE_END + // STEP_START cuckoo String res1 = jedis.cfReserve("bikes:models", 1000000); System.out.println(res1); // >>> OK From 3b2f4d510aeffddf90292f0e010d61abd72199b2 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:40:42 +0600 Subject: [PATCH 3/3] Update CuckooFilterExample.java --- src/test/java/io/redis/examples/CuckooFilterExample.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/redis/examples/CuckooFilterExample.java b/src/test/java/io/redis/examples/CuckooFilterExample.java index 91a79bbf2e..33b8403843 100644 --- a/src/test/java/io/redis/examples/CuckooFilterExample.java +++ b/src/test/java/io/redis/examples/CuckooFilterExample.java @@ -9,7 +9,7 @@ public class CuckooFilterExample { @Test - public void run(){ + public void run() { UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379"); // HIDE_END @@ -21,6 +21,10 @@ public void run(){ String res1 = jedis.cfReserve("bikes:models", 1000000); System.out.println(res1); // >>> OK + // REMOVE_START + Assert.assertEquals(res1, "OK"); + // REMOVE_END + boolean res2 = jedis.cfAdd("bikes:models", "Smoky Mountain Striker"); System.out.println(res2); // >>> True @@ -32,11 +36,10 @@ public void run(){ 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 + // STEP_END } }