java之redis篇(spring-data-redis整合)
java之redis篇(spring-data-redis整合)
redis的知识:官网
1,利用spring-data-redis整合
项目使用的pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion><groupId>com.x.redis</groupId>
<artifactId>Spring_redis</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging><name>Spring_redis</name>
<url>http://maven.apache.org</url><properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties><dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.2.RELEASE</version>
</dependency><span style="color: #0000ff;"><</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span>redis.clients<span style="color: #0000ff;"></</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span>jedis<span style="color: #0000ff;"></</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span>2.1.0<span style="color: #0000ff;"></</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span>junit<span style="color: #0000ff;"></</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span>junit<span style="color: #0000ff;"></</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span>4.8.2<span style="color: #0000ff;"></</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">scope</span><span style="color: #0000ff;">></span>test<span style="color: #0000ff;"></</span><span style="color: #800000;">scope</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span>org.slf4j<span style="color: #0000ff;"></</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span>slf4j-api<span style="color: #0000ff;"></</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span>1.6.1<span style="color: #0000ff;"></</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #008000;"><!--</span><span style="color: #008000;"> 将现有的jakarta commons logging的调用转换成lsf4j的调用。 </span><span style="color: #008000;">--></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span>org.slf4j<span style="color: #0000ff;"></</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span>jcl-over-slf4j<span style="color: #0000ff;"></</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span>1.6.1<span style="color: #0000ff;"></</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #008000;"><!--</span><span style="color: #008000;"> Hack:确保commons-logging的jar包不被引入,否则将和jcl-over-slf4j冲突 </span><span style="color: #008000;">--></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span>commons-logging<span style="color: #0000ff;"></</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span>commons-logging<span style="color: #0000ff;"></</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span>1.1.1<span style="color: #0000ff;"></</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">scope</span><span style="color: #0000ff;">></span>provided<span style="color: #0000ff;"></</span><span style="color: #800000;">scope</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #008000;"><!--</span><span style="color: #008000;"> slf4j的实现:logback,用来取代log4j。更快、更强! </span><span style="color: #008000;">--></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span>ch.qos.logback<span style="color: #0000ff;"></</span><span style="color: #800000;">groupId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span>logback-classic<span style="color: #0000ff;"></</span><span style="color: #800000;">artifactId</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span>0.9.24<span style="color: #0000ff;"></</span><span style="color: #800000;">version</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">scope</span><span style="color: #0000ff;">></span>runtime<span style="color: #0000ff;"></</span><span style="color: #800000;">scope</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">dependency</span><span style="color: #0000ff;">></span>
</dependencies>
</project>
除了log部分,只有一个spring core 和 spring-data-redis了
项目文件目录结构:
applicationContext.xml:
1,context:property-placeholder 标签用来导入properties文件。从而替换${redis.maxIdle}这样的变量。
2,context:component-scan 是为了在com.x.redis.dao报下的类能够实用spring的注解注入的方式。
3,事实上我们只需要把JedisPoolConfig配数来就好了,接下来就是spring的封装了。所以直接看UserDAOImpl的实现就明白了。
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><span style="color: #0000ff;"><</span><span style="color: #800000;">context:property-placeholder </span><span style="color: #ff0000;">location</span><span style="color: #0000ff;">="classpath:redis.properties"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">context:component-scan </span><span style="color: #ff0000;">base-package</span><span style="color: #0000ff;">="com.x.redis.dao"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">context:component-scan</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">bean </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="poolConfig"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="redis.clients.jedis.JedisPoolConfig"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="maxIdle"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="${redis.maxIdle}"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="maxActive"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="${redis.maxActive}"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="maxWait"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="${redis.maxWait}"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="testOnBorrow"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="${redis.testOnBorrow}"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">bean</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">bean </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="connectionFactory"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"</span><span style="color: #ff0000;"> p:host-name</span><span style="color: #0000ff;">="${redis.host}"</span><span style="color: #ff0000;"> p:port</span><span style="color: #0000ff;">="${redis.port}"</span><span style="color: #ff0000;"> p:password</span><span style="color: #0000ff;">="${redis.pass}"</span><span style="color: #ff0000;"> p:pool-config-ref</span><span style="color: #0000ff;">="poolConfig"</span><span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">bean </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="redisTemplate"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="org.springframework.data.redis.core.StringRedisTemplate"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="connectionFactory"</span><span style="color: #ff0000;"> ref</span><span style="color: #0000ff;">="connectionFactory"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">bean</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">bean </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="userDAO"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="com.x.redis.dao.impl.UserDAOImpl"</span> <span style="color: #0000ff;">/></span>
</beans>
redis.properties:
# Redis settings
#redis.host=192.168.20.101
#redis.port=6380
#redis.pass=foobared
redis.host=127.0.0.1
redis.port=6379
redis.pass=
redis.maxIdle=300
redis.maxActive=600
redis.maxWait=1000
redis.testOnBorrow=true
UserDAOImpl:
1,spring对dao层的封装很多用了类似于下面代码的模板方式。
2,RedisTemplate就是spring对redis的一个封装而已。
public class UserDAOImpl implements UserDAO {@Autowired </span><span style="color: #0000ff;">protected</span> RedisTemplate<Serializable, Serializable><span style="color: #000000;"> redisTemplate; </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> saveUser(<span style="color: #0000ff;">final</span><span style="color: #000000;"> User user) { redisTemplate.execute(</span><span style="color: #0000ff;">new</span> RedisCallback<Object><span style="color: #000000;">() { @Override </span><span style="color: #0000ff;">public</span> Object doInRedis(RedisConnection connection) <span style="color: #0000ff;">throws</span><span style="color: #000000;"> DataAccessException { connection.set(redisTemplate.getStringSerializer().serialize(</span>"user.uid." +<span style="color: #000000;"> user.getId()), redisTemplate.getStringSerializer().serialize(user.getName())); </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">; } }); } @Override </span><span style="color: #0000ff;">public</span> User getUser(<span style="color: #0000ff;">final</span> <span style="color: #0000ff;">long</span><span style="color: #000000;"> id) { </span><span style="color: #0000ff;">return</span> redisTemplate.execute(<span style="color: #0000ff;">new</span> RedisCallback<User><span style="color: #000000;">() { @Override </span><span style="color: #0000ff;">public</span> User doInRedis(RedisConnection connection) <span style="color: #0000ff;">throws</span><span style="color: #000000;"> DataAccessException { </span><span style="color: #0000ff;">byte</span>[] key = redisTemplate.getStringSerializer().serialize("user.uid." +<span style="color: #000000;"> id); </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (connection.exists(key)) { </span><span style="color: #0000ff;">byte</span>[] value =<span style="color: #000000;"> connection.get(key); String name </span>=<span style="color: #000000;"> redisTemplate.getStringSerializer().deserialize(value); User user </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> User(); user.setName(name); user.setId(id); </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> user; } </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">; } }); }
}
其他:
User:
public class User {</span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">long</span><span style="color: #000000;"> id; </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> String name; </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">long</span><span style="color: #000000;"> getId() { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> id; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> setId(<span style="color: #0000ff;">long</span><span style="color: #000000;"> id) { </span><span style="color: #0000ff;">this</span>.id =<span style="color: #000000;"> id; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String getName() { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> name; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> setName(String name) { </span><span style="color: #0000ff;">this</span>.name =<span style="color: #000000;"> name; }
}
测试代码:
public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml"); UserDAO userDAO = (UserDAO)ac.getBean("userDAO"); User user1 = new User(); user1.setId(1); user1.setName("obama"); userDAO.saveUser(user1); User user2 = userDAO.getUser(1); System.out.println(user2.getName()); }
2,不利用spring-data-redis整合
个人觉得这样整合灵活度更大,能够更加明了的完成任务。
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion><groupId>com.d.work</groupId>
<artifactId>Redis_Templete</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging><name>Redis_Templete</name>
<url>http://maven.apache.org</url><properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties><dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<!-- 将现有的jakarta commons logging的调用转换成lsf4j的调用。 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.1</version>
</dependency>
<!-- Hack:确保commons-logging的jar包不被引入,否则将和jcl-over-slf4j冲突 -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<!-- slf4j的实现:logback,用来取代log4j。更快、更强! -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.24</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
目录结构:
data-source.xml
1,context:property-placeholder 和 context:component-scan 前面解释过啦。
2,配置了一个ShardedJedisPool,在jdeis里 还有个JedisPool。这两个的区别:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><span style="color: #0000ff;"><</span><span style="color: #800000;">context:property-placeholder </span><span style="color: #ff0000;">location</span><span style="color: #0000ff;">="classpath:redis.properties"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">context:component-scan </span><span style="color: #ff0000;">base-package</span><span style="color: #0000ff;">="com.d.work.main"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">context:component-scan</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">context:component-scan </span><span style="color: #ff0000;">base-package</span><span style="color: #0000ff;">="com.d.work.redis"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">context:component-scan</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">bean </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="jedisPoolConfig"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="redis.clients.jedis.JedisPoolConfig"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="maxActive"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="50"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="maxIdle"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="8"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="maxWait"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="1000"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="testOnBorrow"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="true"</span><span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="testOnReturn"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="true"</span><span style="color: #0000ff;">/></span> <span style="color: #008000;"><!--</span><span style="color: #008000;"> <property name="testWhileIdle" value="true"/> </span><span style="color: #008000;">--></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">bean</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">bean </span><span style="color: #ff0000;">id</span><span style="color: #0000ff;">="shardedJedisPool"</span><span style="color: #ff0000;"> class</span><span style="color: #0000ff;">="redis.clients.jedis.ShardedJedisPool"</span><span style="color: #ff0000;"> scope</span><span style="color: #0000ff;">="singleton"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">constructor-arg </span><span style="color: #ff0000;">index</span><span style="color: #0000ff;">="0"</span><span style="color: #ff0000;"> ref</span><span style="color: #0000ff;">="jedisPoolConfig"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">constructor-arg </span><span style="color: #ff0000;">index</span><span style="color: #0000ff;">="1"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">list</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">bean </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="redis.clients.jedis.JedisShardInfo"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">constructor-arg </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="host"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="${redis.host}"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">constructor-arg </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="port"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="${redis.port}"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">constructor-arg </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="timeout"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="${redis.timeout}"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">constructor-arg </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="weight"</span><span style="color: #ff0000;"> value</span><span style="color: #0000ff;">="1"</span> <span style="color: #0000ff;">/></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">bean</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">list</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">constructor-arg</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">bean</span><span style="color: #0000ff;">></span>
</beans>
RedisDataSource:定义三个方法
public interface RedisDataSource { public abstract ShardedJedis getRedisClient(); public void returnResource(ShardedJedis shardedJedis); public void returnResource(ShardedJedis shardedJedis,boolean broken); }
实现redisDataSource:
1, 注入配置好的ShardedJedisPool,这三个方法的作用:
getRedisClient() : 取得redis的客户端,可以执行命令了。
returnResource(ShardedJedis shardedJedis) : 将资源返还给pool
returnResource(ShardedJedis shardedJedis, boolean broken) : 出现异常后,将资源返还给pool (其实不需要第二个方法)
@Repository("redisDataSource") public class RedisDataSourceImpl implements RedisDataSource {</span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">final</span> Logger log = LoggerFactory.getLogger(RedisDataSourceImpl.<span style="color: #0000ff;">class</span><span style="color: #000000;">); @Autowired </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> ShardedJedisPool shardedJedisPool; </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> ShardedJedis getRedisClient() { </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { ShardedJedis shardJedis </span>=<span style="color: #000000;"> shardedJedisPool.getResource(); </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> shardJedis; } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(</span>"getRedisClent error"<span style="color: #000000;">, e); } </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> returnResource(ShardedJedis shardedJedis) { shardedJedisPool.returnResource(shardedJedis); } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> returnResource(ShardedJedis shardedJedis, <span style="color: #0000ff;">boolean</span><span style="color: #000000;"> broken) { </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (broken) { shardedJedisPool.returnBrokenResource(shardedJedis); } </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { shardedJedisPool.returnResource(shardedJedis); } }
}
第二层的封装:RedisClientTemplate,例子实现了放值和取值。最后代码提供了全部命令的实现。
代码就是映射性质的又一次调用jedis的方法而已,用了个broken来做标示符,决定返还资源的方式。
这一层的目的主要也是让再上层的调用不需要关心pool中链接的取得和返还问题了。
@Repository("redisClientTemplate") public class RedisClientTemplate {</span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">final</span> Logger log = LoggerFactory.getLogger(RedisClientTemplate.<span style="color: #0000ff;">class</span><span style="color: #000000;">); @Autowired </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> RedisDataSource redisDataSource; </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> disconnect() { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); shardedJedis.disconnect(); } </span><span style="color: #008000;">/**</span><span style="color: #008000;"> * 设置单个值 * * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> key * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> value * </span><span style="color: #808080;">@return</span> <span style="color: #008000;">*/</span> <span style="color: #0000ff;">public</span><span style="color: #000000;"> String set(String key, String value) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.set(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #008000;">/**</span><span style="color: #008000;"> * 获取单个值 * * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> key * </span><span style="color: #808080;">@return</span> <span style="color: #008000;">*/</span> <span style="color: #0000ff;">public</span><span style="color: #000000;"> String get(String key) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.get(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; }
}
测试代码:
public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/data-source.xml"); RedisClientTemplate redisClient = (RedisClientTemplate)ac.getBean("redisClientTemplate"); redisClient.set("a", "abc"); System.out.println(redisClient.get("a")); }
附上RedisClientTemplate全部实现:
@Repository("redisClientTemplate") public class RedisClientTemplate {</span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">final</span> Logger log = LoggerFactory.getLogger(RedisClientTemplate.<span style="color: #0000ff;">class</span><span style="color: #000000;">); @Autowired </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> RedisDataSource redisDataSource; </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> disconnect() { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); shardedJedis.disconnect(); } </span><span style="color: #008000;">/**</span><span style="color: #008000;"> * 设置单个值 * * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> key * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> value * </span><span style="color: #808080;">@return</span> <span style="color: #008000;">*/</span> <span style="color: #0000ff;">public</span><span style="color: #000000;"> String set(String key, String value) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.set(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #008000;">/**</span><span style="color: #008000;"> * 获取单个值 * * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> key * </span><span style="color: #808080;">@return</span> <span style="color: #008000;">*/</span> <span style="color: #0000ff;">public</span><span style="color: #000000;"> String get(String key) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.get(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Boolean exists(String key) { Boolean result </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.exists(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String type(String key) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.type(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #008000;">/**</span><span style="color: #008000;"> * 在某段时间后实现 * * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> key * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> unixTime * </span><span style="color: #808080;">@return</span> <span style="color: #008000;">*/</span> <span style="color: #0000ff;">public</span> Long expire(String key, <span style="color: #0000ff;">int</span><span style="color: #000000;"> seconds) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.expire(key, seconds); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #008000;">/**</span><span style="color: #008000;"> * 在某个时间点失效 * * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> key * </span><span style="color: #808080;">@param</span><span style="color: #008000;"> unixTime * </span><span style="color: #808080;">@return</span> <span style="color: #008000;">*/</span> <span style="color: #0000ff;">public</span> Long expireAt(String key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> unixTime) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.expireAt(key, unixTime); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long ttl(String key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.ttl(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">boolean</span> setbit(String key, <span style="color: #0000ff;">long</span> offset, <span style="color: #0000ff;">boolean</span><span style="color: #000000;"> value) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">boolean</span> result = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.setbit(key, offset, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">boolean</span> getbit(String key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> offset) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">boolean</span> result = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getbit(key, offset); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">long</span> setrange(String key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> offset, String value) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">long</span> result = 0<span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.setrange(key, offset, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String getrange(String key, <span style="color: #0000ff;">long</span> startOffset, <span style="color: #0000ff;">long</span><span style="color: #000000;"> endOffset) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getrange(key, startOffset, endOffset); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String getSet(String key, String value) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getSet(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long setnx(String key, String value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.setnx(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String setex(String key, <span style="color: #0000ff;">int</span><span style="color: #000000;"> seconds, String value) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.setex(key, seconds, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long decrBy(String key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> integer) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.decrBy(key, integer); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long decr(String key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.decr(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long incrBy(String key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> integer) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.incrBy(key, integer); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long incr(String key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.incr(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long append(String key, String value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.append(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String substr(String key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.substr(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long hset(String key, String field, String value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hset(key, field, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String hget(String key, String field) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hget(key, field); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long hsetnx(String key, String field, String value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hsetnx(key, field, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String hmset(String key, Map<String, String><span style="color: #000000;"> hash) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hmset(key, hash); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<String><span style="color: #000000;"> hmget(String key, String... fields) { List</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hmget(key, fields); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long hincrBy(String key, String field, <span style="color: #0000ff;">long</span><span style="color: #000000;"> value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hincrBy(key, field, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Boolean hexists(String key, String field) { Boolean result </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hexists(key, field); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long del(String key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.del(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long hdel(String key, String field) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hdel(key, field); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long hlen(String key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hlen(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<String><span style="color: #000000;"> hkeys(String key) { Set</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hkeys(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<String><span style="color: #000000;"> hvals(String key) { List</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hvals(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Map<String, String><span style="color: #000000;"> hgetAll(String key) { Map</span><String, String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hgetAll(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #008000;">//</span><span style="color: #008000;"> ================list ====== l表示 list或 left, r表示right====================</span> <span style="color: #0000ff;">public</span><span style="color: #000000;"> Long rpush(String key, String string) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.rpush(key, string); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long lpush(String key, String string) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lpush(key, string); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long llen(String key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.llen(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<String> lrange(String key, <span style="color: #0000ff;">long</span> start, <span style="color: #0000ff;">long</span><span style="color: #000000;"> end) { List</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lrange(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String ltrim(String key, <span style="color: #0000ff;">long</span> start, <span style="color: #0000ff;">long</span><span style="color: #000000;"> end) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.ltrim(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String lindex(String key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> index) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lindex(key, index); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String lset(String key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> index, String value) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lset(key, index, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long lrem(String key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> count, String value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lrem(key, count, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String lpop(String key) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lpop(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String rpop(String key) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.rpop(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #008000;">//</span><span style="color: #008000;">return 1 add a not exist value , </span><span style="color: #008000;">//</span><span style="color: #008000;">return 0 add a exist value</span> <span style="color: #0000ff;">public</span><span style="color: #000000;"> Long sadd(String key, String member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.sadd(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<String><span style="color: #000000;"> smembers(String key) { Set</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.smembers(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long srem(String key, String member) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.srem(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String spop(String key) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.spop(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long scard(String key) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.scard(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Boolean sismember(String key, String member) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); Boolean result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.sismember(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String srandmember(String key) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.srandmember(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zadd(String key, <span style="color: #0000ff;">double</span><span style="color: #000000;"> score, String member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zadd(key, score, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<String> zrange(String key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Set</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrange(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long zrem(String key, String member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrem(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Double zincrby(String key, <span style="color: #0000ff;">double</span><span style="color: #000000;"> score, String member) { Double result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zincrby(key, score, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long zrank(String key, String member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrank(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long zrevrank(String key, String member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrank(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<String> zrevrange(String key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Set</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrange(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrangeWithScores(String key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeWithScores(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrevrangeWithScores(String key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeWithScores(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long zcard(String key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zcard(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Double zscore(String key, String member) { Double result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zscore(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<String><span style="color: #000000;"> sort(String key) { List</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.sort(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<String><span style="color: #000000;"> sort(String key, SortingParams sortingParameters) { List</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.sort(key, sortingParameters); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zcount(String key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span><span style="color: #000000;"> max) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zcount(key, min, max); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<String> zrangeByScore(String key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span><span style="color: #000000;"> max) { Set</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeByScore(key, min, max); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<String> zrevrangeByScore(String key, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">double</span><span style="color: #000000;"> min) { Set</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeByScore(key, max, min); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<String> zrangeByScore(String key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span><span style="color: #000000;"> count) { Set</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeByScore(key, min, max, offset, count); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<String> zrevrangeByScore(String key, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span><span style="color: #000000;"> count) { Set</span><String> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeByScore(key, max, min, offset, count); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrangeByScoreWithScores(String key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span><span style="color: #000000;"> max) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeByScoreWithScores(key, min, max); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrevrangeByScoreWithScores(String key, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">double</span><span style="color: #000000;"> min) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeByScoreWithScores(key, max, min); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrangeByScoreWithScores(String key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span><span style="color: #000000;"> count) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeByScoreWithScores(key, min, max, offset, count); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrevrangeByScoreWithScores(String key, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span><span style="color: #000000;"> count) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeByScoreWithScores(key, max, min, offset, count); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zremrangeByRank(String key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zremrangeByRank(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zremrangeByScore(String key, <span style="color: #0000ff;">double</span> start, <span style="color: #0000ff;">double</span><span style="color: #000000;"> end) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zremrangeByScore(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Long linsert(String key, LIST_POSITION where, String pivot, String value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.linsert(key, where, pivot, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String set(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.set(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] get(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.get(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Boolean exists(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Boolean result </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.exists(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String type(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.type(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long expire(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span><span style="color: #000000;"> seconds) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.expire(key, seconds); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long expireAt(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> unixTime) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.expireAt(key, unixTime); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long ttl(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.ttl(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] getSet(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getSet(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long setnx(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.setnx(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String setex(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> seconds, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.setex(key, seconds, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long decrBy(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> integer) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.decrBy(key, integer); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long decr(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.decr(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long incrBy(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">long</span><span style="color: #000000;"> integer) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.incrBy(key, integer); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long incr(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.incr(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long append(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.append(key, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] substr(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.substr(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long hset(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span>[] field, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hset(key, field, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] hget(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] field) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hget(key, field); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long hsetnx(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span>[] field, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hsetnx(key, field, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String hmset(<span style="color: #0000ff;">byte</span>[] key, Map<<span style="color: #0000ff;">byte</span>[], <span style="color: #0000ff;">byte</span>[]><span style="color: #000000;"> hash) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hmset(key, hash); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<<span style="color: #0000ff;">byte</span>[]> hmget(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[]... fields) { List</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hmget(key, fields); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long hincrBy(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span>[] field, <span style="color: #0000ff;">long</span><span style="color: #000000;"> value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hincrBy(key, field, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Boolean hexists(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] field) { Boolean result </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hexists(key, field); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long hdel(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] field) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hdel(key, field); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long hlen(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hlen(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<<span style="color: #0000ff;">byte</span>[]> hkeys(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Set</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hkeys(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Collection<<span style="color: #0000ff;">byte</span>[]> hvals(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Collection</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hvals(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Map<<span style="color: #0000ff;">byte</span>[], <span style="color: #0000ff;">byte</span>[]> hgetAll(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Map</span><<span style="color: #0000ff;">byte</span>[], <span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.hgetAll(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long rpush(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] string) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.rpush(key, string); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long lpush(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] string) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lpush(key, string); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long llen(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.llen(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<<span style="color: #0000ff;">byte</span>[]> lrange(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { List</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lrange(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String ltrim(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.ltrim(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] lindex(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span><span style="color: #000000;"> index) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lindex(key, index); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> String lset(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> index, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lset(key, index, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long lrem(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> count, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lrem(key, count, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] lpop(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.lpop(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] rpop(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.rpop(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long sadd(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.sadd(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<<span style="color: #0000ff;">byte</span>[]> smembers(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Set</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.smembers(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long srem(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.srem(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] spop(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.spop(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long scard(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.scard(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Boolean sismember(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Boolean result </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.sismember(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">byte</span>[] srandmember(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { </span><span style="color: #0000ff;">byte</span>[] result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.srandmember(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zadd(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> score, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zadd(key, score, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<<span style="color: #0000ff;">byte</span>[]> zrange(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Set</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrange(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zrem(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrem(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Double zincrby(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> score, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Double result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zincrby(key, score, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zrank(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrank(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zrevrank(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrank(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<<span style="color: #0000ff;">byte</span>[]> zrevrange(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Set</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrange(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrangeWithScores(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeWithScores(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrevrangeWithScores(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeWithScores(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zcard(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zcard(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Double zscore(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] member) { Double result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zscore(key, member); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<<span style="color: #0000ff;">byte</span>[]> sort(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { List</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.sort(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<<span style="color: #0000ff;">byte</span>[]> sort(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key, SortingParams sortingParameters) { List</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.sort(key, sortingParameters); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zcount(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span><span style="color: #000000;"> max) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zcount(key, min, max); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<<span style="color: #0000ff;">byte</span>[]> zrangeByScore(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span><span style="color: #000000;"> max) { Set</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeByScore(key, min, max); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<<span style="color: #0000ff;">byte</span>[]> zrangeByScore(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span><span style="color: #000000;"> count) { Set</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeByScore(key, min, max, offset, count); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrangeByScoreWithScores(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span><span style="color: #000000;"> max) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeByScoreWithScores(key, min, max); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrangeByScoreWithScores(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span><span style="color: #000000;"> count) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrangeByScoreWithScores(key, min, max, offset, count); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<<span style="color: #0000ff;">byte</span>[]> zrevrangeByScore(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">double</span><span style="color: #000000;"> min) { Set</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeByScore(key, max, min); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<<span style="color: #0000ff;">byte</span>[]> zrevrangeByScore(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span><span style="color: #000000;"> count) { Set</span><<span style="color: #0000ff;">byte</span>[]> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeByScore(key, max, min, offset, count); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrevrangeByScoreWithScores(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">double</span><span style="color: #000000;"> min) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeByScoreWithScores(key, max, min); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Set<Tuple> zrevrangeByScoreWithScores(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> max, <span style="color: #0000ff;">double</span> min, <span style="color: #0000ff;">int</span> offset, <span style="color: #0000ff;">int</span><span style="color: #000000;"> count) { Set</span><Tuple> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zrevrangeByScoreWithScores(key, max, min, offset, count); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zremrangeByRank(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">int</span> start, <span style="color: #0000ff;">int</span><span style="color: #000000;"> end) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zremrangeByRank(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long zremrangeByScore(<span style="color: #0000ff;">byte</span>[] key, <span style="color: #0000ff;">double</span> start, <span style="color: #0000ff;">double</span><span style="color: #000000;"> end) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.zremrangeByScore(key, start, end); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Long linsert(<span style="color: #0000ff;">byte</span>[] key, LIST_POSITION where, <span style="color: #0000ff;">byte</span>[] pivot, <span style="color: #0000ff;">byte</span><span style="color: #000000;">[] value) { Long result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.linsert(key, where, pivot, value); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> List<Object><span style="color: #000000;"> pipelined(ShardedJedisPipeline shardedJedisPipeline) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); List</span><Object> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.pipelined(shardedJedisPipeline); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Jedis getShard(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); Jedis result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getShard(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Jedis getShard(String key) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); Jedis result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getShard(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> JedisShardInfo getShardInfo(<span style="color: #0000ff;">byte</span><span style="color: #000000;">[] key) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); JedisShardInfo result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getShardInfo(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> JedisShardInfo getShardInfo(String key) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); JedisShardInfo result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getShardInfo(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> String getKeyTag(String key) { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); String result </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getKeyTag(key); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Collection<JedisShardInfo><span style="color: #000000;"> getAllShardInfo() { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); Collection</span><JedisShardInfo> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getAllShardInfo(); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">public</span> Collection<Jedis><span style="color: #000000;"> getAllShards() { ShardedJedis shardedJedis </span>=<span style="color: #000000;"> redisDataSource.getRedisClient(); Collection</span><Jedis> result = <span style="color: #0000ff;">null</span><span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (shardedJedis == <span style="color: #0000ff;">null</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; } </span><span style="color: #0000ff;">boolean</span> broken = <span style="color: #0000ff;">false</span><span style="color: #000000;">; </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { result </span>=<span style="color: #000000;"> shardedJedis.getAllShards(); } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) { log.error(e.getMessage(), e); broken </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">finally</span><span style="color: #000000;"> { redisDataSource.returnResource(shardedJedis, broken); } </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> result; }
}
</div>
<div class="postDesc">posted @ <span id="post-date">2014-04-12 10:24</span> <a href="http://www.cnblogs.com/tankaixiong/">tankaixiong</a> 阅读(<span id="post_view_count">98108</span>) 评论(<span id="post_comment_count">13</span>) <a href="https://i.cnblogs.com/EditPosts.aspx?postid=3660075" rel="nofollow">编辑</a> <a href="#" onclick="AddToWz(3660075);return false;">收藏</a></div>
</div>
<script type="text/javascript">var allowComments=true,cb_blogId=77284,cb_entryId=3660075,cb_blogApp=currentBlogApp,cb_blogUserGuid='31421efa-e183-df11-ba8f-001cf0cd104b',cb_entryCreatedDate='2014/4/12 10:24:00';loadViewCount(cb_entryId);</script>