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 (c) 2011 Jonathan Leibiusky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
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.pipeline.BuilderFactory;
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.SafeEncoder;
/**
* The Class RedisCluster.
*
* @author jaehong.kim
*/
public class RedisCluster extends BinaryRedisCluster implements
RedisClusterCommands {
/**
* Instantiates a new redis cluster.
*
* @param host the host
*/
public RedisCluster(final String host) {
super(host);
}
/**
* Instantiates a new redis cluster.
*
* @param host the host
* @param port the port
*/
public RedisCluster(final String host, final int port) {
super(host, port);
}
/**
* Instantiates a new redis cluster.
*
* @param host the host
* @param port the port
* @param timeout the timeout
*/
public RedisCluster(final String host, final int port, final int timeout) {
super(host, port, timeout);
}
public RedisCluster(final String host, final int port, final int timeout, final boolean async) {
super(host, port, timeout, async);
}
// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// Keys
public Long del(final String... keys) {
client.del(keys);
return client.getIntegerReply();
}
public Boolean exists(final String key) {
client.exists(key);
return client.getIntegerReply() == 1;
}
public Long exists(final String... keys) {
client.exists(keys);
return client.getIntegerReply();
}
public Long expire(final String key, final int seconds) {
client.expire(key, seconds);
return client.getIntegerReply();
}
public Long expireAt(final String key, final long secondsTimestamp) {
client.expireAt(key, secondsTimestamp);
return client.getIntegerReply();
}
public Long pexpire(final String key, final long milliseconds) {
client.pexpire(key, milliseconds);
return client.getIntegerReply();
}
public Long pexpireAt(final String key, final long millisecondsTimestamp) {
client.pexpireAt(key, millisecondsTimestamp);
return client.getIntegerReply();
}
public Long objectRefcount(String string) {
client.objectRefcount(string);
return client.getIntegerReply();
}
public String objectEncoding(String string) {
client.objectEncoding(string);
return client.getBulkReply();
}
public Long objectIdletime(String string) {
client.objectIdletime(string);
return client.getIntegerReply();
}
public Long ttl(final String key) {
client.ttl(key);
return client.getIntegerReply();
}
public Long pttl(final String key) {
client.pttl(key);
return client.getIntegerReply();
}
public String type(final String key) {
client.type(key);
return client.getStatusCodeReply();
}
public Long persist(final String key) {
client.persist(key);
return client.getIntegerReply();
}
// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// Strings
public Long append(final String key, final String value) {
client.append(key, value);
return client.getIntegerReply();
}
public Long decr(final String key) {
client.decr(key);
return client.getIntegerReply();
}
public Long decrBy(final String key, final long integer) {
client.decrBy(key, integer);
return client.getIntegerReply();
}
public String get(final String key) {
client.get(key);
return client.getBulkReply();
}
public Boolean getbit(String key, long offset) {
client.getbit(key, offset);
return client.getIntegerReply() == 1;
}
public String getrange(String key, long startOffset, long endOffset) {
client.getrange(key, startOffset, endOffset);
return client.getBulkReply();
}
public String substr(final String key, final int start, final int end) {
client.substr(key, start, end);
return client.getBulkReply();
}
public String getSet(final String key, final String value) {
client.getSet(key, value);
return client.getBulkReply();
}
public Long incr(final String key) {
client.incr(key);
return client.getIntegerReply();
}
public Long incrBy(final String key, final long integer) {
client.incrBy(key, integer);
return client.getIntegerReply();
}
public Double incrByFloat(final String key, final double increment) {
client.incrByFloat(key, increment);
String reply = client.getBulkReply();
return (reply != null ? new Double(reply) : null);
}
public String set(final String key, String value) {
client.set(key, value);
return client.getStatusCodeReply();
}
public String set(final String key, final String value, final String nxxx, final String expx, final long time) {
client.set(key, value, nxxx, expx, time);
return client.getStatusCodeReply();
}
public Boolean setbit(String key, long offset, boolean value) {
client.setbit(key, offset, value);
return client.getIntegerReply() == 1;
}
public String setex(final String key, final int seconds, final String value) {
client.setex(key, seconds, value);
return client.getStatusCodeReply();
}
public Long setnx(final String key, final String value) {
client.setnx(key, value);
return client.getIntegerReply();
}
public Long setrange(String key, long offset, String value) {
client.setrange(key, offset, value);
return client.getIntegerReply();
}
public Long strlen(final String key) {
client.strlen(key);
return client.getIntegerReply();
}
public List mget(final String... keys) {
client.mget(keys);
return client.getMultiBulkReply();
}
public String psetex(final String key, final long milliseconds,
final String value) {
client.psetex(key, milliseconds, value);
return client.getStatusCodeReply();
}
public String mset(String... keysvalues) {
client.mset(keysvalues);
return client.getStatusCodeReply();
}
public Long bitcount(final String key) {
client.bitcount(key);
return client.getIntegerReply();
}
public Long bitcount(final String key, long start, long end) {
client.bitcount(key, start, end);
return client.getIntegerReply();
}
public Long bitpos(String key, boolean bit) {
client.bitpos(key, bit);
return client.getIntegerReply();
}
public Long bitpos(String key, boolean bit, int start) {
client.bitpos(key, bit, start);
return client.getIntegerReply();
}
public Long bitpos(String key, boolean bit, int start, int end) {
client.bitpos(key, bit, start, end);
return client.getIntegerReply();
}
public List bitfield(final String key, final String... arguments) {
client.bitfield(key, arguments);
return client.getIntegerMultiBulkReply();
}
// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// Hashes
public Long hdel(final String key, final String... fields) {
client.hdel(key, fields);
return client.getIntegerReply();
}
public Boolean hexists(final String key, final String field) {
client.hexists(key, field);
return client.getIntegerReply() == 1;
}
public String hget(final String key, final String field) {
client.hget(key, field);
return client.getBulkReply();
}
public Map hgetAll(final String key) {
client.hgetAll(key);
return BuilderFactory.STRING_MAP
.build(client.getBinaryMultiBulkReply());
}
public Long hincrBy(final String key, final String field, final long value) {
client.hincrBy(key, field, value);
return client.getIntegerReply();
}
public Double hincrByFloat(final String key, final String field,
double increment) {
client.hincrByFloat(key, field, increment);
String reply = client.getBulkReply();
return (reply != null ? new Double(reply) : null);
}
public Set hkeys(final String key) {
client.hkeys(key);
return BuilderFactory.STRING_SET
.build(client.getBinaryMultiBulkReply());
}
public Long hlen(final String key) {
client.hlen(key);
return client.getIntegerReply();
}
public List hmget(final String key, final String... fields) {
client.hmget(key, fields);
return client.getMultiBulkReply();
}
public String hmset(final String key, final Map hash) {
client.hmset(key, hash);
return client.getStatusCodeReply();
}
public ScanResult scan(final String cursor) {
return scan(cursor, new ScanParams());
}
public ScanResult scan(final String cursor, final ScanParams params) {
client.scan(cursor, params);
List