Last active
August 29, 2015 14:00
-
-
Save yangl/5ee3cca379fff1c98700 to your computer and use it in GitHub Desktop.
JedisTemplate 支持数据分片,实现ShardedJedisPool.java所有方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> | |
<property name="minIdle" value="${redis.minIdle}"/> | |
<property name="maxIdle" value="${redis.maxIdle}"/> | |
<property name="maxTotal" value="${redis.maxTotal}"/> | |
<property name="maxWaitMillis" value="${redis.maxWaitMillis}"/> | |
<property name="testOnBorrow" value="false"/> | |
<property name="testOnReturn" value="false"/> | |
<property name="testWhileIdle" value="true"/> | |
</bean> | |
<bean id="jedisShardInfo" class="redis.clients.jedis.JedisShardInfo" abstract="true"> | |
<constructor-arg index="2" value="${redis.timeout}" type="int"/> | |
</bean> | |
<bean id="jedis1" parent="jedisShardInfo"> | |
<constructor-arg index="0" value="${redis.server1.host}"/> | |
<constructor-arg index="1" value="${redis.server1.port}"/> | |
</bean> | |
<bean id="jedis2" parent="jedisShardInfo"> | |
<constructor-arg index="0" value="${redis.server2.host}"/> | |
<constructor-arg index="1" value="${redis.server2.port}"/> | |
</bean> | |
<bean id="shardedJedisPool" class="redis.clients.jedis.ShardedJedisPool" destroy-method="destroy"> | |
<constructor-arg index="0" ref="jedisPoolConfig"/> | |
<constructor-arg index="1"> | |
<list> | |
<ref bean="jedis1"/> | |
<ref bean="jedis2"/> | |
</list> | |
</constructor-arg> | |
</bean> | |
<bean id="jedisTemplate" class="com.gionee.promotion.common.JedisTemplate"> | |
<property name="shardedJedisPool" ref="shardedJedisPool"/> | |
</bean> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jd.promotion.common; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import redis.clients.jedis.*; | |
import redis.clients.jedis.exceptions.JedisConnectionException; | |
import redis.clients.jedis.exceptions.JedisException; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Set; | |
/** | |
* Jedis 数据分片、回收资源操作 | |
* | |
* @author YAGNLiiN | |
* @date 2014-04-25 17:32 | |
*/ | |
public class JedisTemplate { | |
Logger logger = LoggerFactory.getLogger(JedisTemplate.class); | |
private ShardedJedisPool shardedJedisPool; | |
/** | |
* 执行有返回结果的action。 | |
*/ | |
public <T> T execute(JedisAction<T> jedisAction) throws JedisException { | |
ShardedJedis jedis = null; | |
boolean broken = false; | |
try { | |
jedis = shardedJedisPool.getResource(); | |
return jedisAction.action(jedis); | |
} | |
catch (JedisConnectionException e) { | |
logger.error("Redis connection lost.", e); | |
broken = true; | |
throw e; | |
} | |
finally { | |
if (broken) { | |
shardedJedisPool.returnBrokenResource(jedis); | |
} | |
else { | |
shardedJedisPool.returnResource(jedis); | |
} | |
} | |
} | |
/** | |
* 有返回结果的回调接口定义。 | |
*/ | |
public interface JedisAction<T> { | |
T action(ShardedJedis jedis); | |
} | |
// ************** 常用方法的封装 ************* | |
public String set(final String key, final String value) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.set(key, value); | |
} | |
}); | |
} | |
public String get(final String key) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.get(key); | |
} | |
}); | |
} | |
public String echo(final String string) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.echo(string); | |
} | |
}); | |
} | |
public Boolean exists(final String key) { | |
return execute(new JedisAction<Boolean>() { | |
@Override | |
public Boolean action(ShardedJedis jedis) { | |
return jedis.exists(key); | |
} | |
}); | |
} | |
public String type(final String key) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.type(key); | |
} | |
}); | |
} | |
public Long expire(final String key, final int seconds) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.expire(key, seconds); | |
} | |
}); | |
} | |
public Long expireAt(final String key, final long unixTime) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.expireAt(key, unixTime); | |
} | |
}); | |
} | |
public Long ttl(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.ttl(key); | |
} | |
}); | |
} | |
public Boolean setbit(final String key, final long offset, final boolean value) { | |
return execute(new JedisAction<Boolean>() { | |
@Override | |
public Boolean action(ShardedJedis jedis) { | |
return jedis.setbit(key, offset, value); | |
} | |
}); | |
} | |
public Boolean setbit(final String key, final long offset, final String value) { | |
return execute(new JedisAction<Boolean>() { | |
@Override | |
public Boolean action(ShardedJedis jedis) { | |
return jedis.setbit(key, offset, value); | |
} | |
}); | |
} | |
public Boolean getbit(final String key, final long offset) { | |
return execute(new JedisAction<Boolean>() { | |
@Override | |
public Boolean action(ShardedJedis jedis) { | |
return jedis.getbit(key, offset); | |
} | |
}); | |
} | |
public Long setrange(final String key, final long offset, final String value) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.setrange(key, offset, value); | |
} | |
}); | |
} | |
public String getrange(final String key, final long startOffset, final long endOffset) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.getrange(key, startOffset, endOffset); | |
} | |
}); | |
} | |
public String getSet(final String key, final String value) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.getSet(key, value); | |
} | |
}); | |
} | |
public Long setnx(final String key, final String value) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.setnx(key, value); | |
} | |
}); | |
} | |
public String setex(final String key, final int seconds, final String value) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.setex(key, seconds, value); | |
} | |
}); | |
} | |
public List<String> blpop(final String arg) { | |
return execute(new JedisAction<List<String>>() { | |
@Override | |
public List<String> action(ShardedJedis jedis) { | |
return jedis.blpop(arg); | |
} | |
}); | |
} | |
public List<String> brpop(final String arg) { | |
return execute(new JedisAction<List<String>>() { | |
@Override | |
public List<String> action(ShardedJedis jedis) { | |
return jedis.brpop(arg); | |
} | |
}); | |
} | |
public Long decrBy(final String key, final long integer) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.decrBy(key, integer); | |
} | |
}); | |
} | |
public Long decr(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.decr(key); | |
} | |
}); | |
} | |
public Long incrBy(final String key, final long integer) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.incrBy(key, integer); | |
} | |
}); | |
} | |
public Long incr(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.incr(key); | |
} | |
}); | |
} | |
public Long append(final String key, final String value) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.append(key, value); | |
} | |
}); | |
} | |
public String substr(final String key, final int start, final int end) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.substr(key, start, end); | |
} | |
}); | |
} | |
public Long hset(final String key, final String field, final String value) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.hset(key, field, value); | |
} | |
}); | |
} | |
public String hget(final String key, final String field) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.hget(key, field); | |
} | |
}); | |
} | |
public Long hsetnx(final String key, final String field, final String value) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.hsetnx(key, field, value); | |
} | |
}); | |
} | |
public String hmset(final String key, final Map<String, String> hash) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.hmset(key, hash); | |
} | |
}); | |
} | |
public List<String> hmget(final String key, final String... fields) { | |
return execute(new JedisAction<List<String>>() { | |
@Override | |
public List<String> action(ShardedJedis jedis) { | |
return jedis.hmget(key, fields); | |
} | |
}); | |
} | |
public Long hincrBy(final String key, final String field, final long value) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.hincrBy(key, field, value); | |
} | |
}); | |
} | |
public Boolean hexists(final String key, final String field) { | |
return execute(new JedisAction<Boolean>() { | |
@Override | |
public Boolean action(ShardedJedis jedis) { | |
return jedis.hexists(key, field); | |
} | |
}); | |
} | |
public Long del(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.del(key); | |
} | |
}); | |
} | |
public Long hdel(final String key, final String... fields) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.hdel(key, fields); | |
} | |
}); | |
} | |
public Long hlen(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.hlen(key); | |
} | |
}); | |
} | |
public Set<String> hkeys(final String key) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.hkeys(key); | |
} | |
}); | |
} | |
public List<String> hvals(final String key) { | |
return execute(new JedisAction<List<String>>() { | |
@Override | |
public List<String> action(ShardedJedis jedis) { | |
return jedis.hvals(key); | |
} | |
}); | |
} | |
public Map<String, String> hgetAll(final String key) { | |
return execute(new JedisAction<Map<String, String>>() { | |
@Override | |
public Map<String, String> action(ShardedJedis jedis) { | |
return jedis.hgetAll(key); | |
} | |
}); | |
} | |
public Long rpush(final String key, final String... strings) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.rpush(key, strings); | |
} | |
}); | |
} | |
public Long lpush(final String key, final String... strings) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.lpush(key, strings); | |
} | |
}); | |
} | |
public Long lpushx(final String key, final String... string) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.lpushx(key, string); | |
} | |
}); | |
} | |
public Long strlen(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.strlen(key); | |
} | |
}); | |
} | |
public Long move(final String key, final int dbIndex) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.move(key, dbIndex); | |
} | |
}); | |
} | |
public Long rpushx(final String key, final String... string) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.rpushx(key, string); | |
} | |
}); | |
} | |
public Long persist(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.persist(key); | |
} | |
}); | |
} | |
public Long llen(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.llen(key); | |
} | |
}); | |
} | |
public List<String> lrange(final String key, final long start, final long end) { | |
return execute(new JedisAction<List<String>>() { | |
@Override | |
public List<String> action(ShardedJedis jedis) { | |
return jedis.lrange(key, start, end); | |
} | |
}); | |
} | |
public String ltrim(final String key, final long start, final long end) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.ltrim(key, start, end); | |
} | |
}); | |
} | |
public String lindex(final String key, final long index) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.lindex(key, index); | |
} | |
}); | |
} | |
public String lset(final String key, final long index, final String value) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.lset(key, index, value); | |
} | |
}); | |
} | |
public Long lrem(final String key, final long count, final String value) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.lrem(key, count, value); | |
} | |
}); | |
} | |
public String lpop(final String key) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.lpop(key); | |
} | |
}); | |
} | |
public String rpop(final String key) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.rpop(key); | |
} | |
}); | |
} | |
public Long sadd(final String key, final String... members) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.sadd(key, members); | |
} | |
}); | |
} | |
public Set<String> smembers(final String key) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.smembers(key); | |
} | |
}); | |
} | |
public Long srem(final String key, final String... members) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.srem(key, members); | |
} | |
}); | |
} | |
public String spop(final String key) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.spop(key); | |
} | |
}); | |
} | |
public Long scard(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.scard(key); | |
} | |
}); | |
} | |
public Boolean sismember(final String key, final String member) { | |
return execute(new JedisAction<Boolean>() { | |
@Override | |
public Boolean action(ShardedJedis jedis) { | |
return jedis.sismember(key, member); | |
} | |
}); | |
} | |
public String srandmember(final String key) { | |
return execute(new JedisAction<String>() { | |
@Override | |
public String action(ShardedJedis jedis) { | |
return jedis.srandmember(key); | |
} | |
}); | |
} | |
public Long zadd(final String key, final double score, final String member) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zadd(key, score, member); | |
} | |
}); | |
} | |
public Long zadd(final String key, final Map<String, Double> scoreMembers) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zadd(key, scoreMembers); | |
} | |
}); | |
} | |
public Set<String> zrange(final String key, final long start, final long end) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrange(key, start, end); | |
} | |
}); | |
} | |
public Long zrem(final String key, final String... members) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zrem(key, members); | |
} | |
}); | |
} | |
public Double zincrby(final String key, final double score, final String member) { | |
return execute(new JedisAction<Double>() { | |
@Override | |
public Double action(ShardedJedis jedis) { | |
return jedis.zincrby(key, score, member); | |
} | |
}); | |
} | |
public Long zrank(final String key, final String member) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zrank(key, member); | |
} | |
}); | |
} | |
public Long zrevrank(final String key, final String member) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zrevrank(key, member); | |
} | |
}); | |
} | |
public Set<String> zrevrange(final String key, final long start, final long end) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrevrange(key, start, end); | |
} | |
}); | |
} | |
public Set<Tuple> zrangeWithScores(final String key, final long start, final long end) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrangeWithScores(key, start, end); | |
} | |
}); | |
} | |
public Set<Tuple> zrevrangeWithScores(final String key, final long start, final long end) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrevrangeWithScores(key, start, end); | |
} | |
}); | |
} | |
public Long zcard(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zcard(key); | |
} | |
}); | |
} | |
public Double zscore(final String key, final String member) { | |
return execute(new JedisAction<Double>() { | |
@Override | |
public Double action(ShardedJedis jedis) { | |
return jedis.zscore(key, member); | |
} | |
}); | |
} | |
public List<String> sort(final String key) { | |
return execute(new JedisAction<List<String>>() { | |
@Override | |
public List<String> action(ShardedJedis jedis) { | |
return jedis.sort(key); | |
} | |
}); | |
} | |
public List<String> sort(final String key, final SortingParams sortingParameters) { | |
return execute(new JedisAction<List<String>>() { | |
@Override | |
public List<String> action(ShardedJedis jedis) { | |
return jedis.sort(key, sortingParameters); | |
} | |
}); | |
} | |
public Long zcount(final String key, final double min, final double max) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zcount(key, min, max); | |
} | |
}); | |
} | |
public Long zcount(final String key, final String min, final String max) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zcount(key, min, max); | |
} | |
}); | |
} | |
public Set<String> zrangeByScore(final String key, final double min, final double max) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrangeByScore(key, min, max); | |
} | |
}); | |
} | |
public Set<String> zrevrangeByScore(final String key, final double max, final double min) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrevrangeByScore(key, max, min); | |
} | |
}); | |
} | |
public Set<String> zrangeByScore(final String key, final double min, final double max, final int offset, | |
final int count) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrangeByScore(key, min, max, offset, count); | |
} | |
}); | |
} | |
public Set<String> zrevrangeByScore(final String key, final double max, final double min, | |
final int offset, final int count) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrevrangeByScore(key, max, min, offset, count); | |
} | |
}); | |
} | |
public Set<Tuple> zrangeByScoreWithScores(final String key, final double min, final double max) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrangeByScoreWithScores(key, min, max); | |
} | |
}); | |
} | |
public Set<Tuple> zrevrangeByScoreWithScores(final String key, final double max, final double min) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrevrangeByScoreWithScores(key, max, min); | |
} | |
}); | |
} | |
public Set<Tuple> zrangeByScoreWithScores(final String key, final double min, final double max, | |
final int offset, final int count) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrangeByScoreWithScores(key, min, max, offset, count); | |
} | |
}); | |
} | |
public Set<Tuple> zrevrangeByScoreWithScores(final String key, final double max, final double min, | |
final int offset, final int count) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrevrangeByScoreWithScores(key, max, min, offset, count); | |
} | |
}); | |
} | |
public Set<String> zrangeByScore(final String key, final String min, final String max) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrangeByScore(key, min, max); | |
} | |
}); | |
} | |
public Set<String> zrevrangeByScore(final String key, final String max, final String min) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrevrangeByScore(key, max, min); | |
} | |
}); | |
} | |
public Set<String> zrangeByScore(final String key, final String min, final String max, final int offset, | |
final int count) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrangeByScore(key, min, max, offset, count); | |
} | |
}); | |
} | |
public Set<String> zrevrangeByScore(final String key, final String max, final String min, | |
final int offset, final int count) { | |
return execute(new JedisAction<Set<String>>() { | |
@Override | |
public Set<String> action(ShardedJedis jedis) { | |
return jedis.zrevrangeByScore(key, max, min, offset, count); | |
} | |
}); | |
} | |
public Set<Tuple> zrangeByScoreWithScores(final String key, final String min, final String max) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrangeByScoreWithScores(key, min, max); | |
} | |
}); | |
} | |
public Set<Tuple> zrevrangeByScoreWithScores(final String key, final String max, final String min) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrevrangeByScoreWithScores(key, max, min); | |
} | |
}); | |
} | |
public Set<Tuple> zrangeByScoreWithScores(final String key, final String min, final String max, | |
final int offset, final int count) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrangeByScoreWithScores(key, min, max, offset, count); | |
} | |
}); | |
} | |
public Set<Tuple> zrevrangeByScoreWithScores(final String key, final String max, final String min, | |
final int offset, final int count) { | |
return execute(new JedisAction<Set<Tuple>>() { | |
@Override | |
public Set<Tuple> action(ShardedJedis jedis) { | |
return jedis.zrevrangeByScoreWithScores(key, max, min, offset, count); | |
} | |
}); | |
} | |
public Long zremrangeByRank(final String key, final long start, final long end) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zremrangeByRank(key, start, end); | |
} | |
}); | |
} | |
public Long zremrangeByScore(final String key, final double start, final double end) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zremrangeByScore(key, start, end); | |
} | |
}); | |
} | |
public Long zremrangeByScore(final String key, final String start, final String end) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.zremrangeByScore(key, start, end); | |
} | |
}); | |
} | |
public Long linsert(final String key, final BinaryClient.LIST_POSITION where, final String pivot, | |
final String value) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.linsert(key, where, pivot, value); | |
} | |
}); | |
} | |
public Long bitcount(final String key) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.bitcount(key); | |
} | |
}); | |
} | |
public Long bitcount(final String key, final long start, final long end) { | |
return execute(new JedisAction<Long>() { | |
@Override | |
public Long action(ShardedJedis jedis) { | |
return jedis.bitcount(key, start, end); | |
} | |
}); | |
} | |
public ScanResult<Map.Entry<String, String>> hscan(final String key, final String cursor) { | |
return execute(new JedisAction<ScanResult<Map.Entry<String, String>>>() { | |
@Override | |
public ScanResult<Map.Entry<String, String>> action(ShardedJedis jedis) { | |
return jedis.hscan(key, cursor); | |
} | |
}); | |
} | |
public ScanResult<String> sscan(final String key, final String cursor) { | |
return execute(new JedisAction<ScanResult<String>>() { | |
@Override | |
public ScanResult<String> action(ShardedJedis jedis) { | |
return jedis.sscan(key, cursor); | |
} | |
}); | |
} | |
public ScanResult<Tuple> zscan(final String key, final String cursor) { | |
return execute(new JedisAction<ScanResult<Tuple>>() { | |
@Override | |
public ScanResult<Tuple> action(ShardedJedis jedis) { | |
return jedis.zscan(key, cursor); | |
} | |
}); | |
} | |
public ShardedJedisPool getShardedJedisPool() { | |
return shardedJedisPool; | |
} | |
public void setShardedJedisPool(ShardedJedisPool shardedJedisPool) { | |
this.shardedJedisPool = shardedJedisPool; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment