-
Notifications
You must be signed in to change notification settings - Fork 3.9k
DOC-4445 server management command examples #4056
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
Merged
sazzad16
merged 7 commits into
redis:master
from
andy-stark-redis:DOC-4445-server-mgmt-cmd-examples
Jan 20, 2025
+58
−0
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3f5789a
DOC-4445 server management command examples
andy-stark-redis 377cc3b
Merge branch 'master' into DOC-4445-server-mgmt-cmd-examples
andy-stark-redis c3e7287
Merge branch 'master' into DOC-4445-server-mgmt-cmd-examples
andy-stark-redis 8ac8c47
DOC-4445 implemented info command example with Jedis class
andy-stark-redis a164ae8
Apply suggestions from code review
andy-stark-redis 0db8a4e
DOC-4445 implemented feedback
andy-stark-redis 00417e6
Merge branch 'master' into DOC-4445-server-mgmt-cmd-examples
andy-stark-redis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
src/test/java/io/redis/examples/CmdsServerMgmtExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // EXAMPLE: cmds_servermgmt | ||
| // REMOVE_START | ||
| package io.redis.examples; | ||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
| // REMOVE_END | ||
| import java.util.Set; | ||
|
|
||
| import redis.clients.jedis.Jedis; | ||
| // HIDE_START | ||
| import redis.clients.jedis.UnifiedJedis; | ||
|
|
||
| public class CmdsServerMgmtExample { | ||
| @Test | ||
| public void run() { | ||
| UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379"); | ||
sazzad16 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // HIDE_END | ||
|
|
||
| // 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 | ||
| // Note: you must use the `Jedis` class to access the `info` | ||
| // command rather than `UnifiedJedis`. | ||
| Jedis jedis2 = new Jedis("redis://localhost:6379"); | ||
|
|
||
| String infoResult = jedis2.info(); | ||
|
|
||
| // Check the first 8 characters of the result (the full `info` string | ||
| // is much longer than this). | ||
| System.out.println(infoResult.substring(0, 8)); // >>> # Server | ||
|
|
||
| jedis2.close(); | ||
| // STEP_END | ||
| // REMOVE_START | ||
| Assert.assertEquals("# Server", infoResult.substring(0, 8)); | ||
| // REMOVE_END | ||
|
|
||
| // HIDE_START | ||
| jedis.close(); | ||
| } | ||
| } | ||
| // HIDE_END | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.