Skip to content

Commit

Permalink
Add more comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Jan 19, 2024
1 parent 7a49ff8 commit 285665c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
5 changes: 5 additions & 0 deletions java/client/src/main/java/glide/api/RedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public CompletableFuture<String> ping(String msg) {
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details.
* @return CompletableFuture with the response
*/
@Override
public CompletableFuture<Map> info() {
Command command = Command.builder().requestType(Command.RequestType.INFO).build();
return commandManager.submitNewCommand(command, ResponseHandlers::handleMapResponse);
Expand All @@ -130,6 +131,7 @@ public CompletableFuture<Map> info() {
* retrieve. When no parameter is provided, the default option is assumed.
* @return CompletableFuture with the response
*/
@Override
public CompletableFuture<Map> info(InfoOptions options) {
Command command =
Command.builder()
Expand All @@ -146,6 +148,7 @@ public CompletableFuture<Map> info(InfoOptions options) {
* @param key - The key to retrieve from the database.
* @return If `key` exists, returns the value of `key` as a string. Otherwise, return null
*/
@Override
public CompletableFuture<String> get(String key) {
Command command =
Command.builder()
Expand All @@ -163,6 +166,7 @@ public CompletableFuture<String> get(String key) {
* @param value - The value to store with the given key.
* @return null
*/
@Override
public CompletableFuture<Void> set(String key, String value) {
Command command =
Command.builder()
Expand All @@ -182,6 +186,7 @@ public CompletableFuture<Void> set(String key, String value) {
* @return string or null If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist`
* conditions, return null. If `returnOldValue` is set, return the old value as a string.
*/
@Override
public CompletableFuture<String> set(String key, String value, SetOptions options) {
Command command =
Command.builder()
Expand Down
20 changes: 14 additions & 6 deletions java/client/src/main/java/glide/api/models/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,34 @@ public enum RequestType {

/** CONNECTION MANAGEMENT COMMANDS * */

/** */
/**
* Ping the Redis server.
*
* @see <a href="https://redis.io/commands/ping/">redis.io</a> for details.
*/
PING,

/** SERVER MANAGEMENT COMMANDS * */

/** */
/**
* Get information and statistics about the Redis server
*
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details.
*/
INFO,

/** STRING COMMANDS * */

/**
* Get the value of key.
* Get the value associated with the given key, or null if no such value exists.
*
* @see: <href=https://redis.io/commands/get/>command reference</a>
* @see <a href="https://redis.io/commands/get/">redis.io</a> for details.
*/
GET_STRING,
/**
* Set key to hold the string value.
* Set the given key with the given value.
*
* @see: <href=https://redis.io/commands/set/>command reference</a>
* @see <a href="https://redis.io/commands/set/">redis.io</a> for details.
*/
SET_STRING,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package glide.api.models.commands;

import glide.api.commands.ServerCommands;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.Builder;
import lombok.NonNull;
import lombok.Singular;

/** Object builder to add optional arguments to {@link ServerCommands#info(InfoOptions)} */
@Builder
@NonNull
public class InfoOptions extends Options {

@Singular private final List<Section> sections;
Expand Down Expand Up @@ -51,7 +51,7 @@ public enum Section {
}

/**
* Converts options enum into a String[]
* Converts options enum into a String[] to add to a {@link glide.api.models.Command}
*
* @return String[]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import java.util.LinkedList;
import java.util.List;

public class Options {
/** Options base object to Options to a {@link glide.api.models.Command} */
public abstract class Options {

protected List optionArgs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import lombok.Builder;
import lombok.NonNull;

/**
* Object builder to add optional arguments to {@link glide.api.commands.StringCommands#set(String,
* String, SetOptions)}
*/
@Builder
@NonNull
public class SetOptions extends Options {

/**
Expand Down Expand Up @@ -86,6 +89,11 @@ public enum TimeToLiveType {
public static String TIME_TO_LIVE_UNIX_SECONDS = "EXAT";
public static String TIME_TO_LIVE_UNIX_MILLISECONDS = "PXAT";

/**
* Converts SetOptions into a String[] to add to a {@link glide.api.models.Command}
* @param arguments
* @return
*/
public String[] toSetOptions(List<String> arguments) {
optionArgs = new LinkedList();
if (conditionalSet != null) {
Expand Down

0 comments on commit 285665c

Please sign in to comment.