K
- Key type.V
- Value type.public class CommandArgs<K,V> extends Object
CommandArgs
is a container for multiple singular arguments. Key and Value arguments are
encoded using the RedisCodec
to their byte representation. CommandArgs
provides a fluent style of adding
multiple arguments. A CommandArgs
instance can be reused across multiple commands and invocations.
new CommandArgs<>(codec).addKey(key).addValue(value).add(CommandKeyword.FORCE);
Modifier and Type | Field and Description |
---|---|
protected RedisCodec<K,V> |
codec |
Constructor and Description |
---|
CommandArgs(RedisCodec<K,V> codec) |
Modifier and Type | Method and Description |
---|---|
CommandArgs<K,V> |
add(byte[] value)
Add a byte-array argument.
|
CommandArgs<K,V> |
add(char[] cs)
Add a string as char-array.
|
CommandArgs<K,V> |
add(CommandKeyword keyword)
Add a
CommandKeyword argument. |
CommandArgs<K,V> |
add(CommandType type)
Add a
CommandType argument. |
CommandArgs<K,V> |
add(double n)
Add a double argument.
|
CommandArgs<K,V> |
add(long n)
Add an 64-bit integer (long) argument.
|
CommandArgs<K,V> |
add(Map<K,V> map)
Add a map (hash) argument.
|
CommandArgs<K,V> |
add(ProtocolKeyword keyword)
Add a
ProtocolKeyword argument. |
CommandArgs<K,V> |
add(String s)
Add a string argument.
|
CommandArgs<K,V> |
addAll(CommandArgs<?,?> args)
Add all arguments from
CommandArgs |
CommandArgs<K,V> |
addKey(K key)
Adds a key argument.
|
CommandArgs<K,V> |
addKeys(Iterable<K> keys)
Add multiple key arguments.
|
CommandArgs<K,V> |
addKeys(K... keys)
Add multiple key arguments.
|
CommandArgs<K,V> |
addValue(V value)
Add a value argument.
|
CommandArgs<K,V> |
addValues(Iterable<V> values)
Add multiple value arguments.
|
CommandArgs<K,V> |
addValues(V... values)
Add multiple value arguments.
|
int |
count() |
void |
encode(io.netty.buffer.ByteBuf buf)
Encode the
CommandArgs and write the arguments to the ByteBuf . |
ByteBuffer |
getFirstEncodedKey()
Returns the first key argument in its byte-encoded representation.
|
Long |
getFirstInteger()
Deprecated.
|
String |
getFirstString()
Deprecated.
|
String |
toCommandString()
Returns a command string representation of
CommandArgs with annotated key and value parameters. |
String |
toString() |
protected final RedisCodec<K,V> codec
public CommandArgs(RedisCodec<K,V> codec)
codec
- Codec used to encode/decode keys and values, must not be null
.public int count()
public CommandArgs<K,V> addKey(K key)
key
- the keypublic CommandArgs<K,V> addKeys(Iterable<K> keys)
keys
- must not be null
.@SafeVarargs public final CommandArgs<K,V> addKeys(K... keys)
keys
- must not be null
.public CommandArgs<K,V> addValue(V value)
value
- the valuepublic CommandArgs<K,V> addValues(Iterable<V> values)
values
- must not be null
.@SafeVarargs public final CommandArgs<K,V> addValues(V... values)
values
- must not be null
.public CommandArgs<K,V> add(Map<K,V> map)
map
- the map, must not be null
.public CommandArgs<K,V> add(String s)
s
- the string.public CommandArgs<K,V> add(char[] cs)
cs
- the string.public CommandArgs<K,V> add(long n)
n
- the argument.public CommandArgs<K,V> add(double n)
n
- the double argument.public CommandArgs<K,V> add(byte[] value)
value
- the byte-array.public CommandArgs<K,V> add(CommandKeyword keyword)
CommandKeyword
argument. The argument is represented as bulk string.keyword
- must not be null
.public CommandArgs<K,V> add(CommandType type)
CommandType
argument. The argument is represented as bulk string.type
- must not be null
.public CommandArgs<K,V> add(ProtocolKeyword keyword)
ProtocolKeyword
argument. The argument is represented as bulk string.keyword
- the keyword, must not be null
public CommandArgs<K,V> addAll(CommandArgs<?,?> args)
CommandArgs
args
- the args, must not be null
public String toCommandString()
CommandArgs
with annotated key and value parameters.
args.addKey("mykey").add(2.0)
will return key<mykey> 2.0
.@Deprecated public Long getFirstInteger()
null
.@Deprecated public String getFirstString()
null
.public ByteBuffer getFirstEncodedKey()
null
.public void encode(io.netty.buffer.ByteBuf buf)
CommandArgs
and write the arguments to the ByteBuf
.buf
- the target buffer.Copyright © 2024 lettuce.io. All rights reserved.