From 3f5789ad060b3036ded67f169baf877f8af5db19 Mon Sep 17 00:00:00 2001 From: Andy Stark Date: Wed, 15 Jan 2025 14:23:01 +0000 Subject: [PATCH] DOC-4445 server management command examples --- .../redis/examples/CmdsServerMgmtExample.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/test/java/io/redis/examples/CmdsServerMgmtExample.java diff --git a/src/test/java/io/redis/examples/CmdsServerMgmtExample.java b/src/test/java/io/redis/examples/CmdsServerMgmtExample.java new file mode 100644 index 0000000000..1890e1869d --- /dev/null +++ b/src/test/java/io/redis/examples/CmdsServerMgmtExample.java @@ -0,0 +1,43 @@ +// EXAMPLE: cmds_servermgmt +// REMOVE_START +package io.redis.examples; + +import org.junit.Assert; +import org.junit.Test; +// REMOVE_END +import java.util.Set; + +// HIDE_START +import redis.clients.jedis.UnifiedJedis; + +public class CmdsServerMgmtExample { + @Test + public void run() { + UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379"); + + // STEP_START flushall + //REMOVE_START + jedis.set("testkey1", "1"); + jedis.set("testkey2", "2"); + jedis.set("testkey3", "3"); + //REMOVE_END + String flushAllResult1 = jedis.flushAll(); + System.out.println(flushAllResult1); // >>> OK + + Set flushAllResult2 = jedis.keys("*"); + System.out.println(flushAllResult2); // >>> [] + // STEP_END + // REMOVE_START + Assert.assertEquals("OK", flushAllResult1); + Assert.assertEquals("[]", flushAllResult2.toString()); + // REMOVE_END + + // STEP_START info + + // Not currently supported by Jedis. + + // STEP_END + +// HIDE_END + } +} \ No newline at end of file