-
Notifications
You must be signed in to change notification settings - Fork 0
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 part of the 'String Commands' group to RedisClient as specified on the official Redis website. #68
Conversation
@@ -318,4 +318,170 @@ public void set_withOptionsOnlyIfDoesNotExist_success() | |||
assertNotNull(response); | |||
assertEquals(value, response.get()); | |||
} | |||
|
|||
@Test | |||
public void decr_success() throws ExecutionException, InterruptedException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we planning to add non-successful cases?
* Add base command; add custom command --------- Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
… on the official Redis website.
df8b07d
to
1dcc052
Compare
6340d2f
to
c8a54bb
Compare
* | ||
* @see <a href="https://redis.io/commands/decr/">redis.io</a> for details. | ||
* @param key - The key to decrement its value. | ||
* @return the value of `key` after the decrement. An error is raised if `key` contains a value of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return the value of `key` after the decrement. An error is raised if `key` contains a value of | |
* @return The value of `key` after the decrement. An error is raised if `key` contains a value of |
Keep the casing consistend across the docs (update below too)
import java.util.concurrent.CompletableFuture; | ||
|
||
/** String Commands interface to handle single commands that return Strings. */ | ||
/** | ||
* String Commands interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a bit confusing, becase string commands don't return strings actually.
* String Commands interface. | |
* Commands that perform string manipulation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to leave here tests which required to provide test coverage, but all meaningful test move to IT, where you can execute a command without mocking anything.
Probably, wait for valkey-io#863 to merge or rebase on IT test branch.
Please, also fix CI (again spotless, oh) and update PR description with examples and list of commands implemented |
* @see <a href="https://redis.io/commands/incrby/">redis.io</a> for details. | ||
* @param key - The key to increment its value. | ||
* @param amount - The amount to increment. | ||
* @returns the value of `key` after the increment, An error is raised if `key` contains a value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important: the tag should be @return
- please update everywhere
* @returns the value of `key` after the increment, An error is raised if `key` contains a value | |
* @return The value of `key` after the increment, An error is raised if `key` contains a value |
Changed return type for MGET (from Object[] to String[]). Minor fixes in tests.
* @param msg - the ping argument that will be returned. | ||
* @returns return a copy of the argument. | ||
* @param msg The ping argument that will be returned. | ||
* @return Return a copy of the argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Seems like in the other docs we don't do "@return Return"
* @return Return a copy of the argument. | |
* @return A copy of the argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return Return a copy of the argument. | |
* @return A server response |
* @param key The key to store. | ||
* @param value The value to store with the given key. | ||
* @param options The Set options | ||
* @return String or null If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: taking this from the python client docs:
* @return String or null If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` | |
* @return The old value as a string if `returnOldValue` is set. Otherwise, if the value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist`, return null. Otherwise, return "OK". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use {@link returnOldValue}
(add proper link) instead of just `returnOldValue`
* | ||
* @see <a href="https://redis.io/commands/incr/">redis.io</a> for details. | ||
* @param key The key to increment its value. | ||
* @return The value of `key` after the increment, An error is raised if `key` contains a value of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this should be a period instead of comma, same thing applies for other occurrences in this PR
* @return The value of `key` after the increment, An error is raised if `key` contains a value of | |
* @return The value of `key` after the increment. An error is raised if `key` contains a value of |
* @param args arguments for the custom command | ||
* @return a CompletableFuture with response result from Redis | ||
* @param args Arguments for the custom command | ||
* @return A CompletableFuture with response result from Redis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed, you can simplify that - here and for all other functions (except CreateClient
I think)
* @return A CompletableFuture with response result from Redis | |
* @return A response from Redis |
@@ -92,7 +94,7 @@ public CompletableFuture<Object> customCommand(String[] args) { | |||
* Ping the Redis server. | |||
* | |||
* @see <a href="https://redis.io/commands/ping/">redis.io</a> for details. | |||
* @returns the String "PONG" | |||
* @return The String "PONG" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return The String "PONG" | |
* @return A server response |
* @param msg - the ping argument that will be returned. | ||
* @returns return a copy of the argument. | ||
* @param msg The ping argument that will be returned. | ||
* @return Return a copy of the argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return Return a copy of the argument. | |
* @return A server response |
@@ -133,7 +135,7 @@ public CompletableFuture<Map> info() { | |||
* Get information and statistics about the Redis server. | |||
* | |||
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details. | |||
* @param options - A list of InfoSection values specifying which sections of information to | |||
* @param options A list of InfoSection values specifying which sections of information to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param options A list of InfoSection values specifying which sections of information to | |
* @param options A list of {@link InfoSection} values specifying which sections of information to |
@@ -133,7 +135,7 @@ public CompletableFuture<Map> info() { | |||
* Get information and statistics about the Redis server. | |||
* | |||
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details. | |||
* @param options - A list of InfoSection values specifying which sections of information to | |||
* @param options A list of InfoSection values specifying which sections of information to | |||
* retrieve. When no parameter is provided, the default option is assumed. | |||
* @return CompletableFuture with the response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return CompletableFuture with the response | |
* @return A server response |
List<String> flatMap = new ArrayList<>(); | ||
|
||
for (Map.Entry<String, String> entry : keyValueMap.entrySet()) { | ||
flatMap.add(entry.getKey()); | ||
flatMap.add(entry.getValue()); | ||
} | ||
|
||
String[] args = flatMap.toArray(new String[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can avoid creating intermediate list for better performance
public interface StringCommands { | ||
|
||
CompletableFuture<String> get(String key); | ||
|
||
CompletableFuture<Void> set(String key, String value); | ||
|
||
CompletableFuture<String> set(String key, String value, SetOptions options); | ||
|
||
CompletableFuture<Long> decr(String key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move all javadocs from client to here - for all functions.
@Test | ||
public void set_withOptionsOnlyIfExists_success() | ||
throws ExecutionException, InterruptedException { | ||
public void set_withOptionsOnlyIfExists_success() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename the test
@Test | ||
public void set_withOptionsOnlyIfDoesNotExist_success() | ||
throws ExecutionException, InterruptedException { | ||
public void set_withOptionsOnlyIfDoesNotExist_success() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
|
||
@SneakyThrows | ||
@Test | ||
public void decr_success() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider moving new tests to new file(s)
No description provided.