K
- Key type.V
- Value type.T
- Command output type.public class AsyncCommand<K,V,T> extends CompletableFuture<T> implements RedisCommand<K,V,T>, RedisFuture<T>, CompleteableCommand<T>
CommandOutput
object.CompletableFuture.AsynchronousCompletionTask
Modifier and Type | Field and Description |
---|---|
protected RedisCommand<K,V,T> |
command |
protected CountDownLatch |
latch |
Constructor and Description |
---|
AsyncCommand(RedisCommand<K,V,T> command) |
Modifier and Type | Method and Description |
---|---|
boolean |
await(long timeout,
TimeUnit unit)
Wait up to the specified time for the command output to become available.
|
void |
cancel()
Cancel a command.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
void |
complete()
Mark this command complete and notify all waiting threads.
|
boolean |
completeExceptionally(Throwable ex) |
protected void |
completeResult() |
void |
encode(ByteBuf buf)
Encode the command.
|
CommandArgs<K,V> |
getArgs() |
String |
getError() |
CommandOutput<K,V,T> |
getOutput()
Get the object that holds this command's output.
|
ProtocolKeyword |
getType() |
void |
onComplete(java.util.function.Consumer<? super T> action) |
void |
setOutput(CommandOutput<K,V,T> output)
Set a new output.
|
String |
toString() |
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, complete, completedFuture, exceptionally, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, obtrudeException, obtrudeValue, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsync
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isCancelled, isDone
acceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, exceptionally, handle, handleAsync, handleAsync, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsync
get, get, isCancelled, isDone
protected RedisCommand<K,V,T> command
protected CountDownLatch latch
public AsyncCommand(RedisCommand<K,V,T> command)
command
- the command, must not be null.public boolean await(long timeout, TimeUnit unit)
await
in interface RedisFuture<T>
timeout
- Maximum time to wait for a result.unit
- Unit of time for the timeout.public CommandOutput<K,V,T> getOutput()
getOutput
in interface RedisCommand<K,V,T>
public void complete()
complete
in interface RedisCommand<K,V,T>
protected void completeResult()
public boolean completeExceptionally(Throwable ex)
completeExceptionally
in interface RedisCommand<K,V,T>
completeExceptionally
in class CompletableFuture<T>
ex
- the exceptiontrue
if this invocation caused this CompletableFuture to transition to a completed state, else
false
public boolean cancel(boolean mayInterruptIfRunning)
public String getError()
getError
in interface RedisFuture<T>
public CommandArgs<K,V> getArgs()
getArgs
in interface RedisCommand<K,V,T>
public String toString()
toString
in class CompletableFuture<T>
public ProtocolKeyword getType()
getType
in interface RedisCommand<K,V,T>
public void cancel()
RedisCommand
cancel
in interface RedisCommand<K,V,T>
public void encode(ByteBuf buf)
RedisCommand
encode
in interface RedisCommand<K,V,T>
buf
- byte buffer to operate on.public void setOutput(CommandOutput<K,V,T> output)
RedisCommand
setOutput
in interface RedisCommand<K,V,T>
output
- the new command outputpublic void onComplete(java.util.function.Consumer<? super T> action)
onComplete
in interface CompleteableCommand<T>
Copyright © 2016. All rights reserved.