Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2015 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.redis.cluster;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.navercorp.redis.cluster.connection.RedisProtocol;
import com.navercorp.redis.cluster.pipeline.BuilderFactory;
import com.navercorp.redis.cluster.triples.TriplesRedisCluster;
import redis.clients.jedis.BinaryClient.LIST_POSITION;
import redis.clients.jedis.GeoCoordinate;
import redis.clients.jedis.GeoRadiusResponse;
import redis.clients.jedis.GeoUnit;
import redis.clients.jedis.ScanParams;
import redis.clients.jedis.ScanResult;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.params.geo.GeoRadiusParam;
import redis.clients.jedis.params.sortedset.ZAddParams;
import redis.clients.util.JedisByteHashMap;
import redis.clients.util.SafeEncoder;
/**
* The Class BinaryRedisCluster.
*
* @author jaehong.kim
*/
public class BinaryRedisCluster extends TriplesRedisCluster implements BinaryRedisClusterCommands {
/**
* Instantiates a new binary redis cluster.
*
* @param host the host
*/
public BinaryRedisCluster(final String host) {
super(host);
}
/**
* Instantiates a new binary redis cluster.
*
* @param host the host
* @param port the port
*/
public BinaryRedisCluster(final String host, final int port) {
super(host, port);
}
/**
* Instantiates a new binary redis cluster.
*
* @param host the host
* @param port the port
* @param timeout the timeout
*/
public BinaryRedisCluster(final String host, final int port, final int timeout) {
super(host, port, timeout);
client = new RedisClusterClient(host, port);
client.setTimeout(timeout);
}
public BinaryRedisCluster(final String host, final int port, final int timeout, boolean async) {
super(host, port, timeout);
client = new RedisClusterClient(host, port, async);
client.setTimeout(timeout);
}
public RedisClusterClient getClient() {
return this.client;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Keys
public Long del(final byte[]... key) {
client.del(key);
return client.getIntegerReply();
}
public Boolean exists(final byte[] key) {
client.exists(key);
return client.getIntegerReply() == 1;
}
public Long exists(final byte[]... keys) {
client.exists(keys);
return client.getIntegerReply();
}
public Long expire(final byte[] key, final int seconds) {
client.expire(key, seconds);
return client.getIntegerReply();
}
public Long expireAt(final byte[] key, final long secondsTimestamp) {
client.expireAt(key, secondsTimestamp);
return client.getIntegerReply();
}
public Long pexpire(final byte[] key, final long milliseconds) {
client.pexpire(key, milliseconds);
return client.getIntegerReply();
}
public Long pexpireAt(final byte[] key, final long millisecondsTimestamp) {
client.pexpireAt(key, millisecondsTimestamp);
return client.getIntegerReply();
}
public byte[] objectEncoding(byte[] key) {
client.objectEncoding(key);
return client.getBinaryBulkReply();
}
public Long objectIdletime(byte[] key) {
client.objectIdletime(key);
return client.getIntegerReply();
}
public Long objectRefcount(byte[] key) {
client.objectRefcount(key);
return client.getIntegerReply();
}
public Long ttl(final byte[] key) {
client.ttl(key);
return client.getIntegerReply();
}
public Long pttl(final byte[] key) {
client.pttl(key);
return client.getIntegerReply();
}
public String type(final byte[] key) {
client.type(key);
return client.getStatusCodeReply();
}
public Long persist(final byte[] key) {
client.persist(key);
return client.getIntegerReply();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Strings
public Long append(final byte[] key, final byte[] value) {
client.append(key, value);
return client.getIntegerReply();
}
public Long decr(final byte[] key) {
client.decr(key);
return client.getIntegerReply();
}
public Long decrBy(final byte[] key, final long integer) {
client.decrBy(key, integer);
return client.getIntegerReply();
}
public byte[] get(final byte[] key) {
client.get(key);
return client.getBinaryBulkReply();
}
public Boolean getbit(byte[] key, long offset) {
client.getbit(key, offset);
return client.getIntegerReply() == 1;
}
public byte[] getrange(byte[] key, long startOffset, long endOffset) {
client.getrange(key, startOffset, endOffset);
return client.getBinaryBulkReply();
}
public byte[] substr(final byte[] key, final int start, final int end) {
client.substr(key, start, end);
return client.getBinaryBulkReply();
}
public byte[] getSet(final byte[] key, final byte[] value) {
client.getSet(key, value);
return client.getBinaryBulkReply();
}
public Long incr(final byte[] key) {
client.incr(key);
return client.getIntegerReply();
}
public Long incrBy(final byte[] key, final long integer) {
client.incrBy(key, integer);
return client.getIntegerReply();
}
public Double incrByFloat(final byte[] key, final double increment) {
client.incrByFloat(key, increment);
final String reply = client.getBulkReply();
return (reply != null ? new Double(reply) : null);
}
public String set(final byte[] key, final byte[] value) {
client.set(key, value);
return client.getStatusCodeReply();
}
public String set(final byte[] key, final byte[] value, final byte[] nxxx, final byte[] expx, final long time) {
client.set(key, value, nxxx, expx, time);
return client.getStatusCodeReply();
}
public Boolean setbit(byte[] key, long offset, byte[] value) {
client.setbit(key, offset, value);
return client.getIntegerReply() == 1;
}
public String setex(final byte[] key, final int seconds, final byte[] value) {
client.setex(key, seconds, value);
return client.getStatusCodeReply();
}
public Long setnx(final byte[] key, final byte[] value) {
client.setnx(key, value);
return client.getIntegerReply();
}
public Long setrange(byte[] key, long offset, byte[] value) {
client.setrange(key, offset, value);
return client.getIntegerReply();
}
public Long strlen(final byte[] key) {
client.strlen(key);
return client.getIntegerReply();
}
public List mget(final byte[]... keys) {
client.mget(keys);
return client.getBinaryMultiBulkReply();
}
public String mset(final byte[]... keysvalues) {
client.mset(keysvalues);
return client.getStatusCodeReply();
}
public String psetex(final byte[] key, final long milliseconds, final byte[] value) {
client.psetex(key, milliseconds, value);
return client.getStatusCodeReply();
}
public Long bitcount(final byte[] key) {
client.bitcount(key);
return client.getIntegerReply();
}
public List bitfield(final byte[] key, final byte[]... arguments) {
client.bitfield(key, arguments);
return client.getIntegerMultiBulkReply();
}
public Long bitcount(final byte[] key, long start, long end) {
client.bitcount(key, start, end);
return client.getIntegerReply();
}
public Long bitpos(byte[] key, boolean bit) {
client.bitpos(key, bit);
return client.getIntegerReply();
}
public Long bitpos(byte[] key, boolean bit, int start) {
client.bitpos(key, bit, start);
return client.getIntegerReply();
}
public Long bitpos(byte[] key, boolean bit, int start, int end) {
client.bitpos(key, bit, start, end);
return client.getIntegerReply();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Hashes
public Long hdel(final byte[] key, final byte[]... fields) {
client.hdel(key, fields);
return client.getIntegerReply();
}
public Boolean hexists(final byte[] key, final byte[] field) {
client.hexists(key, field);
return client.getIntegerReply() == 1;
}
public byte[] hget(final byte[] key, final byte[] field) {
client.hget(key, field);
return client.getBinaryBulkReply();
}
public Map hgetAll(final byte[] key) {
client.hgetAll(key);
final List flatHash = client.getBinaryMultiBulkReply();
final Map hash = new JedisByteHashMap();
if (flatHash == null) {
return hash;
}
final Iterator iterator = flatHash.iterator();
if (iterator == null) {
return hash;
}
while (iterator.hasNext()) {
hash.put(iterator.next(), iterator.next());
}
return hash;
}
public Long hincrBy(final byte[] key, final byte[] field, final long value) {
client.hincrBy(key, field, value);
return client.getIntegerReply();
}
public Double hincrByFloat(final byte[] key, final byte[] field, double increment) {
client.hincrByFloat(key, field, increment);
String reply = client.getBulkReply();
return (reply != null ? new Double(reply) : null);
}
public Set hkeys(final byte[] key) {
client.hkeys(key);
final List lresult = client.getBinaryMultiBulkReply();
return new HashSet(lresult);
}
public Long hlen(final byte[] key) {
client.hlen(key);
return client.getIntegerReply();
}
public List hmget(final byte[] key, final byte[]... fields) {
client.hmget(key, fields);
return client.getBinaryMultiBulkReply();
}
public String hmset(final byte[] key, final Map hash) {
client.hmset(key, hash);
return client.getStatusCodeReply();
}
public ScanResult scan(final byte[] cursor) {
return scan(cursor, new ScanParams());
}
public ScanResult scan(final byte[] cursor, final ScanParams params) {
client.scan(cursor, params);
List