com.aliyun.tair.tairzset.params.ExzaddParams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alibabacloud-tairjedis-sdk Show documentation
Show all versions of alibabacloud-tairjedis-sdk Show documentation
Aliyun Tair Redis client for Java
Copyright (C) Alibaba Cloud Computing
All rights reserved.
版权所有 (C)阿里云计算有限公司
http://www.aliyun.com
package com.aliyun.tair.tairzset.params;
import java.util.ArrayList;
import redis.clients.jedis.params.Params;
import redis.clients.jedis.util.SafeEncoder;
public class ExzaddParams extends Params {
private static final String XX = "xx";
private static final String NX = "nx";
private static final String CH = "ch";
private static final String INCR = "incr";
public ExzaddParams() {
}
public static ExzaddParams ExzaddParams() {
return new ExzaddParams();
}
/**
* Only set the key if it does not already exist.
* @return ExzaddParams
*/
public ExzaddParams nx() {
addParam(NX);
return this;
}
/**
* Only set the key if it already exist.
* @return ExzaddParams
*/
public ExzaddParams xx() {
addParam(XX);
return this;
}
/**
* Modify the return value from the number of new elements added to the total number of elements
* changed
* @return ExzaddParams
*/
public ExzaddParams ch() {
addParam(CH);
return this;
}
public ExzaddParams incr() {
addParam(INCR);
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));
}
if (contains(INCR)) {
byteParams.add(SafeEncoder.encode(INCR));
}
for (byte[] arg : args) {
byteParams.add(arg);
}
return byteParams.toArray(new byte[byteParams.size()][]);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy