-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java/integ acarbo add xtrim refactor options (#253)
* Refactor stream options into a package Signed-off-by: Andrew Carbonetto <[email protected]> * Fix linking Signed-off-by: Andrew Carbonetto <[email protected]> * SPOTLESS Signed-off-by: Andrew Carbonetto <[email protected]> --------- Signed-off-by: Andrew Carbonetto <[email protected]>
- Loading branch information
1 parent
2766989
commit f0bf73a
Showing
10 changed files
with
250 additions
and
248 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
6 changes: 3 additions & 3 deletions
6
java/client/src/main/java/glide/api/commands/StreamBaseCommands.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
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
221 changes: 0 additions & 221 deletions
221
java/client/src/main/java/glide/api/models/commands/StreamOptions.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
java/client/src/main/java/glide/api/models/commands/stream/StreamAddOptions.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,57 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.models.commands.stream; | ||
|
||
import glide.api.commands.StreamBaseCommands; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import lombok.Builder; | ||
|
||
/** | ||
* Optional arguments to {@link StreamBaseCommands#xadd(String, Map, StreamAddOptions)} | ||
* | ||
* @see <a href="https://redis.io/commands/xadd/">redis.io</a> | ||
*/ | ||
@Builder | ||
public final class StreamAddOptions { | ||
public static final String NO_MAKE_STREAM_REDIS_API = "NOMKSTREAM"; | ||
public static final String ID_WILDCARD_REDIS_API = "*"; | ||
|
||
/** If set, the new entry will be added with this <code>id</code>. */ | ||
private final String id; | ||
|
||
/** | ||
* If set to <code>false</code>, a new stream won't be created if no stream matches the given key. | ||
* <br> | ||
* Equivalent to <code>NOMKSTREAM</code> in the Redis API. | ||
*/ | ||
private final Boolean makeStream; | ||
|
||
/** If set, the add operation will also trim the older entries in the stream. */ | ||
private final StreamTrimOptions trim; | ||
|
||
/** | ||
* Converts options for Xadd into a String[]. | ||
* | ||
* @return String[] | ||
*/ | ||
public String[] toArgs() { | ||
List<String> optionArgs = new ArrayList<>(); | ||
|
||
if (makeStream != null && !makeStream) { | ||
optionArgs.add(NO_MAKE_STREAM_REDIS_API); | ||
} | ||
|
||
if (trim != null) { | ||
optionArgs.addAll(trim.getRedisApi()); | ||
} | ||
|
||
if (id != null) { | ||
optionArgs.add(id); | ||
} else { | ||
optionArgs.add(ID_WILDCARD_REDIS_API); | ||
} | ||
|
||
return optionArgs.toArray(new String[0]); | ||
} | ||
} |
Oops, something went wrong.