forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java: Added Hget, Hset and Hdel to BaseClient and BaseTransaction. (H…
…ash Commands) (valkey-io#959) * Java: Added Hget, Hset and Hdel to BaseClient and BaseTransaction. (Hash Commands) (#82) * Added transaction tests. Minor refactor documentation. * Minor updates based on PR comments and rebase. * Fixed TestUtilities, Spotless, minor refactor for code. * Removed error condition in Hdel documentation. * Minor documentation fixes.
- Loading branch information
1 parent
a35ed7d
commit 2b9f9f7
Showing
8 changed files
with
284 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
48 changes: 48 additions & 0 deletions
48
java/client/src/main/java/glide/api/commands/HashCommands.java
This file contains 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,48 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.commands; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Hash Commands interface for both standalone and cluster clients. | ||
* | ||
* @see <a href="https://redis.io/commands/?group=hash">Hash Commands</a> | ||
*/ | ||
public interface HashCommands { | ||
|
||
/** | ||
* Retrieves the value associated with <code>field</code> in the hash stored at <code>key</code>. | ||
* | ||
* @see <a href="https://redis.io/commands/hget/">redis.io</a> for details. | ||
* @param key The key of the hash. | ||
* @param field The field in the hash stored at <code>key</code> to retrieve from the database. | ||
* @return The value associated with <code>field</code>, or <code>null</code> when <code>field | ||
* </code> is not present in the hash or <code>key</code> does not exist. | ||
*/ | ||
CompletableFuture<String> hget(String key, String field); | ||
|
||
/** | ||
* Sets the specified fields to their respective values in the hash stored at <code>key</code>. | ||
* | ||
* @see <a href="https://redis.io/commands/hset/">redis.io</a> for details. | ||
* @param key The key of the hash. | ||
* @param fieldValueMap A field-value map consisting of fields and their corresponding values to | ||
* be set in the hash stored at the specified key. | ||
* @return The number of fields that were added. | ||
*/ | ||
CompletableFuture<Long> hset(String key, Map<String, String> fieldValueMap); | ||
|
||
/** | ||
* Removes the specified fields from the hash stored at <code>key</code>. Specified fields that do | ||
* not exist within this hash are ignored. | ||
* | ||
* @see <a href="https://redis.io/commands/hdel/">redis.io</a> for details. | ||
* @param key The key of the hash. | ||
* @param fields The fields to remove from the hash stored at <code>key</code>. | ||
* @return The number of fields that were removed from the hash, not including specified but | ||
* non-existing fields.<br> | ||
* If <code>key</code> does not exist, it is treated as an empty hash and it returns 0.<br> | ||
*/ | ||
CompletableFuture<Long> hdel(String key, String[] fields); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.