Skip to content

Commit

Permalink
DOC-4445 server management command examples
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-stark-redis committed Jan 15, 2025
1 parent 27ecd6c commit 3f5789a
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/test/java/io/redis/examples/CmdsServerMgmtExample.java
Original file line number Diff line number Diff line change
@@ -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<String> 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
}
}

0 comments on commit 3f5789a

Please sign in to comment.