![JAR search and dependency download from the Maven repository](/logo.png)
redis.clients.jedis.params.sortedset.ZAddParams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jedis Show documentation
Show all versions of jedis Show documentation
A java client for github.com/antirez/redis, a fork of github.com/xetorthio/jedis
package redis.clients.jedis.params.sortedset;
import redis.clients.jedis.params.Params;
import redis.clients.util.SafeEncoder;
import java.util.ArrayList;
public class ZAddParams extends Params {
private static final String XX = "xx";
private static final String NX = "nx";
private static final String CH = "ch";
private ZAddParams() {
}
public static ZAddParams zAddParams() {
return new ZAddParams();
}
/**
* Only set the key if it does not already exist.
* @return ZAddParams
*/
public ZAddParams nx() {
addParam(NX);
return this;
}
/**
* Only set the key if it already exist.
* @return ZAddParams
*/
public ZAddParams xx() {
addParam(XX);
return this;
}
/**
* Modify the return value from the number of new elements added to the total number of elements
* changed
* @return ZAddParams
*/
public ZAddParams ch() {
addParam(CH);
return this;
}
public byte[][] getByteParams(byte[] key, byte[]... args) {
ArrayList byteParams = new ArrayList();
byteParams.add(key);
if (contains(NX)) {
byteParams.add(SafeEncoder.encode(NX));
}
if (contains(XX)) {
byteParams.add(SafeEncoder.encode(XX));
}
if (contains(CH)) {
byteParams.add(SafeEncoder.encode(CH));
}
for (byte[] arg : args) {
byteParams.add(arg);
}
return byteParams.toArray(new byte[byteParams.size()][]);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy