Skip to content

Commit

Permalink
GS version of ttl, pttl, expire, pexpire, expireAt, pexpireAt, expire…
Browse files Browse the repository at this point in the history
…Time, pexpireTime, exists (#1637)

* GS version of ttl, pttl, expire, pexpire, expireAt, pexpireAt, expireTime, pexpireTime, exists

Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
talxsha and Ubuntu authored Jun 26, 2024
1 parent 18b32fe commit 44e4c88
Show file tree
Hide file tree
Showing 5 changed files with 859 additions and 1 deletion.
96 changes: 96 additions & 0 deletions java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,11 @@ public CompletableFuture<Long> exists(@NonNull String[] keys) {
return commandManager.submitNewCommand(Exists, keys, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> exists(@NonNull GlideString[] keys) {
return commandManager.submitNewCommand(Exists, keys, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> unlink(@NonNull String[] keys) {
return commandManager.submitNewCommand(Unlink, keys, this::handleLongResponse);
Expand All @@ -1118,6 +1123,12 @@ public CompletableFuture<Boolean> expire(@NonNull String key, long seconds) {
Expire, new String[] {key, Long.toString(seconds)}, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> expire(@NonNull GlideString key, long seconds) {
return commandManager.submitNewCommand(
Expire, new GlideString[] {key, gs(Long.toString(seconds))}, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> expire(
@NonNull String key, long seconds, @NonNull ExpireOptions expireOptions) {
Expand All @@ -1126,12 +1137,29 @@ public CompletableFuture<Boolean> expire(
return commandManager.submitNewCommand(Expire, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> expire(
@NonNull GlideString key, long seconds, @NonNull ExpireOptions expireOptions) {
GlideString[] arguments =
ArrayUtils.addAll(
new GlideString[] {key, gs(Long.toString(seconds))}, expireOptions.toGlideStringArgs());
return commandManager.submitNewCommand(Expire, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> expireAt(@NonNull String key, long unixSeconds) {
return commandManager.submitNewCommand(
ExpireAt, new String[] {key, Long.toString(unixSeconds)}, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> expireAt(@NonNull GlideString key, long unixSeconds) {
return commandManager.submitNewCommand(
ExpireAt,
new GlideString[] {key, gs(Long.toString(unixSeconds))},
this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> expireAt(
@NonNull String key, long unixSeconds, @NonNull ExpireOptions expireOptions) {
Expand All @@ -1140,12 +1168,30 @@ public CompletableFuture<Boolean> expireAt(
return commandManager.submitNewCommand(ExpireAt, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> expireAt(
@NonNull GlideString key, long unixSeconds, @NonNull ExpireOptions expireOptions) {
GlideString[] arguments =
ArrayUtils.addAll(
new GlideString[] {key, gs(Long.toString(unixSeconds))},
expireOptions.toGlideStringArgs());
return commandManager.submitNewCommand(ExpireAt, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> pexpire(@NonNull String key, long milliseconds) {
return commandManager.submitNewCommand(
PExpire, new String[] {key, Long.toString(milliseconds)}, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> pexpire(@NonNull GlideString key, long milliseconds) {
return commandManager.submitNewCommand(
PExpire,
new GlideString[] {key, gs(Long.toString(milliseconds))},
this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> pexpire(
@NonNull String key, long milliseconds, @NonNull ExpireOptions expireOptions) {
Expand All @@ -1154,6 +1200,16 @@ public CompletableFuture<Boolean> pexpire(
return commandManager.submitNewCommand(PExpire, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> pexpire(
@NonNull GlideString key, long milliseconds, @NonNull ExpireOptions expireOptions) {
GlideString[] arguments =
ArrayUtils.addAll(
new GlideString[] {key, gs(Long.toString(milliseconds))},
expireOptions.toGlideStringArgs());
return commandManager.submitNewCommand(PExpire, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> pexpireAt(@NonNull String key, long unixMilliseconds) {
return commandManager.submitNewCommand(
Expand All @@ -1162,6 +1218,14 @@ public CompletableFuture<Boolean> pexpireAt(@NonNull String key, long unixMillis
this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> pexpireAt(@NonNull GlideString key, long unixMilliseconds) {
return commandManager.submitNewCommand(
PExpireAt,
new GlideString[] {key, gs(Long.toString(unixMilliseconds))},
this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> pexpireAt(
@NonNull String key, long unixMilliseconds, @NonNull ExpireOptions expireOptions) {
Expand All @@ -1171,23 +1235,50 @@ public CompletableFuture<Boolean> pexpireAt(
return commandManager.submitNewCommand(PExpireAt, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> pexpireAt(
@NonNull GlideString key, long unixMilliseconds, @NonNull ExpireOptions expireOptions) {
GlideString[] arguments =
ArrayUtils.addAll(
new GlideString[] {key, gs(Long.toString(unixMilliseconds))},
expireOptions.toGlideStringArgs());
return commandManager.submitNewCommand(PExpireAt, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Long> ttl(@NonNull String key) {
return commandManager.submitNewCommand(TTL, new String[] {key}, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> ttl(@NonNull GlideString key) {
return commandManager.submitNewCommand(TTL, new GlideString[] {key}, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> expiretime(@NonNull String key) {
return commandManager.submitNewCommand(
ExpireTime, new String[] {key}, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> expiretime(@NonNull GlideString key) {
return commandManager.submitNewCommand(
ExpireTime, new GlideString[] {key}, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> pexpiretime(@NonNull String key) {
return commandManager.submitNewCommand(
PExpireTime, new String[] {key}, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> pexpiretime(@NonNull GlideString key) {
return commandManager.submitNewCommand(
PExpireTime, new GlideString[] {key}, this::handleLongResponse);
}

@Override
public CompletableFuture<Object> invokeScript(@NonNull Script script) {
return commandManager.submitScript(
Expand Down Expand Up @@ -1787,6 +1878,11 @@ public CompletableFuture<Long> pttl(@NonNull String key) {
return commandManager.submitNewCommand(PTTL, new String[] {key}, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> pttl(@NonNull GlideString key) {
return commandManager.submitNewCommand(PTTL, new GlideString[] {key}, this::handleLongResponse);
}

@Override
public CompletableFuture<Boolean> persist(@NonNull String key) {
return commandManager.submitNewCommand(
Expand Down
Loading

0 comments on commit 44e4c88

Please sign in to comment.