【第22期】观点:IT 行业加班,到底有没有价值?

Spring整合redis使用Java操作redis

原创 2017年01月03日 11:19:07

项目结构

这里写图片描述

配置文件

这里写图片描述

web.xml

这里写图片描述

  • redis.properties
redis.host1=127.0.0.1
redis.host2=127.0.0.2
redis.port=6379
redis.timeout=20000
  • redisContext.xml这里使用的spring3.0
  • ignore-unresolvable=”true”这属性是加载redis.properties文件需要在spring配文件中也加入此属性加载jdbc.properties文件
<?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-3.0.xsd  
                   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:property-placeholder location="classpath:redis.properties" ignore-unresolvable="true"/>
    <context:component-scan base-package="com.zxtj.redis.*" />
        <!--
            </context:component-scan> <context:component-scan
            base-package="com.d.work.redis"> </context:component-scan>
        -->
        <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">

            <property name="maxIdle" value="8" />

            <property name="testOnBorrow" value="true" />
            <property name="testOnReturn" value="true" />
            <!-- <property name="testWhileIdle" value="true"/> -->
        </bean>

        <bean id="shardedJedisPool" class="redis.clients.jedis.ShardedJedisPool" scope="singleton">
            <constructor-arg index="0" ref="jedisPoolConfig" />
            <constructor-arg index="1">
                <list>
                    <bean class="redis.clients.jedis.JedisShardInfo">
                        <constructor-arg name="host" value="${redis.host1}" />
                        <constructor-arg name="port" value="${redis.port}" />
                        <constructor-arg name="timeout" value="${redis.timeout}" />
                        <constructor-arg name="weight" value="1" />
                    </bean>
                    <bean class="redis.clients.jedis.JedisShardInfo">
                        <constructor-arg name="host" value="${redis.host2}" />
                        <constructor-arg name="port" value="${redis.port}" />
                        <constructor-arg name="timeout" value="${redis.timeout}" />
                        <constructor-arg name="weight" value="1" />
                    </bean>
                </list>
            </constructor-arg>
        </bean>
</beans>

创建redis数据连接接口获取连接


import redis.clients.jedis.ShardedJedis;

/**
 *
 * <redis 获取客户端连接,执行命令>
 */
public interface RedisDataSource {
    /**
     * @return ShardedJedis
     * <获取redis客户端连接,执行命令>
     */
    public abstract ShardedJedis getRedisClient();
    /**
     * @param shardedJedis
     * <将资源返还个pool>
     */
    public void returnResource(ShardedJedis shardedJedis);
    /**
     * @param shardedJedis
     * <出现异常后,将资源返还给pool>
     */  
    public void returnResource(ShardedJedis shardedJedis,boolean broken);
}

RedisDataSource创建实现类

import common.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPool;

import com.zxtj.redis.RedisDataSource;

@Repository(“redisDataSource”)
public class RedisDataSourceImpl implements RedisDataSource {
private static final Logger log = Logger.getLogger(RedisDataSourceImpl.class);

@Autowired
private ShardedJedisPool shardedJedisPool;
/**
 * @return ShardedJedis
 * <获取redis客户端连接,执行命令>
 */
public ShardedJedis getRedisClient() {

    try {
        ShardedJedis shardedJedis = shardedJedisPool.getResource();
        return shardedJedis;
    } catch (Exception e) {
        log.error("获取redis客户端连接失败",e);
    }
    return null;
}
/**
 * 
 * @param shardedJedis
 * <将资源返还个pool>
 */
public void returnResource(ShardedJedis shardedJedis) {

    shardedJedisPool.returnResource(shardedJedis);

}
/**
 * 
 * @param shardedJedis
 * <出现异常后,将资源返还给pool>
 */ 
public void returnResource(ShardedJedis shardedJedis, boolean broken) {

    if(broken){
        shardedJedisPool.returnBrokenResource(shardedJedis);
    }else{
        shardedJedisPool.returnResource(shardedJedis);
    }

}

}

Redis客户端方法模板接口



import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedisPipeline;
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.BinaryClient.LIST_POSITION;

public interface RedisClientTemplate {

    //public abstract void disconnect();

    /**
     * 设置单个值
     * 
     * @param key
     * @param value
     * @return
     */
    public abstract String set(String key, String value);

    /**
     * 获取单个值
     * 
     * @param key
     * @return
     */
    public abstract String get(String key);

    public abstract Boolean exists(String key);

    public abstract String type(String key);

    /**
     * 在某段时间后实现
     * 
     * @param key
     * @param unixTime
     * @return
     */
    public abstract Long expire(String key, int seconds);

    /**
     * 在某个时间点失效
     * 
     * @param key
     * @param unixTime
     * @return
     */
    public abstract Long expireAt(String key, long unixTime);

    public abstract Long ttl(String key);

    public abstract boolean setbit(String key, long offset, boolean value);

    public abstract boolean getbit(String key, long offset);

    public abstract long setrange(String key, long offset, String value);

    public abstract String getrange(String key, long startOffset, long endOffset);

    public abstract String getSet(String key, String value);

    public abstract Long setnx(String key, String value);

    public abstract String setex(String key, int seconds, String value);

    public abstract Long decrBy(String key, long integer);

    public abstract Long decr(String key);

    public abstract Long incrBy(String key, long integer);

    public abstract Long incr(String key);

    public abstract Long append(String key, String value);

    public abstract String substr(String key, int start, int end);

    public abstract Long hset(String key, String field, String value);

    public abstract String hget(String key, String field);

    public abstract Long hsetnx(String key, String field, String value);

    public abstract String hmset(String key, Map<String, String> hash);

    public abstract List<String> hmget(String key, String... fields);

    public abstract Long hincrBy(String key, String field, long value);

    public abstract Boolean hexists(String key, String field);

    public abstract Long del(String key);

    public abstract Long hdel(String key, String field);

    public abstract Long hlen(String key);

    public abstract Set<String> hkeys(String key);

    public abstract List<String> hvals(String key);

    public abstract Map<String, String> hgetAll(String key);

    // ================list ====== l表示 list或 left, r表示right====================
    public abstract Long rpush(String key, String string);

    public abstract Long lpush(String key, String string);

    public abstract Long llen(String key);

    public abstract List<String> lrange(String key, long start, long end);

    public abstract String ltrim(String key, long start, long end);

    public abstract String lindex(String key, long index);

    public abstract String lset(String key, long index, String value);

    public abstract Long lrem(String key, long count, String value);

    public abstract String lpop(String key);

    public abstract String rpop(String key);

    //return 1 add a not exist value ,
    //return 0 add a exist value
    public abstract Long sadd(String key, String member);

    public abstract Set<String> smembers(String key);

    public abstract Long srem(String key, String member);

    public abstract String spop(String key);

    public abstract Long scard(String key);

    public abstract Boolean sismember(String key, String member);

    public abstract String srandmember(String key);

    public abstract Long zadd(String key, double score, String member);

    public abstract Set<String> zrange(String key, int start, int end);

    public abstract Long zrem(String key, String member);

    public abstract Double zincrby(String key, double score, String member);

    public abstract Long zrank(String key, String member);

    public abstract Long zrevrank(String key, String member);

    public abstract Set<String> zrevrange(String key, int start, int end);

    public abstract Set<Tuple> zrangeWithScores(String key, int start, int end);

    public abstract Set<Tuple> zrevrangeWithScores(String key, int start,
            int end);

    public abstract Long zcard(String key);

    public abstract Double zscore(String key, String member);

    public abstract List<String> sort(String key);

    public abstract List<String> sort(String key,
            SortingParams sortingParameters);

    public abstract Long zcount(String key, double min, double max);

    public abstract Set<String> zrangeByScore(String key, double min, double max);

    public abstract Set<String> zrevrangeByScore(String key, double max,
            double min);

    public abstract Set<String> zrangeByScore(String key, double min,
            double max, int offset, int count);

    public abstract Set<String> zrevrangeByScore(String key, double max,
            double min, int offset, int count);

    public abstract Set<Tuple> zrangeByScoreWithScores(String key, double min,
            double max);

    public abstract Set<Tuple> zrevrangeByScoreWithScores(String key,
            double max, double min);

    public abstract Set<Tuple> zrangeByScoreWithScores(String key, double min,
            double max, int offset, int count);

    public abstract Set<Tuple> zrevrangeByScoreWithScores(String key,
            double max, double min, int offset, int count);

    public abstract Long zremrangeByRank(String key, int start, int end);

    public abstract Long zremrangeByScore(String key, double start, double end);

    public abstract Long linsert(String key, LIST_POSITION where, String pivot,
            String value);

    public abstract String set(byte[] key, byte[] value);

    public abstract byte[] get(byte[] key);

    public abstract Boolean exists(byte[] key);

    public abstract String type(byte[] key);

    public abstract Long expire(byte[] key, int seconds);

    public abstract Long expireAt(byte[] key, long unixTime);

    public abstract Long ttl(byte[] key);

    public abstract byte[] getSet(byte[] key, byte[] value);

    public abstract Long setnx(byte[] key, byte[] value);

    public abstract String setex(byte[] key, int seconds, byte[] value);

    public abstract Long decrBy(byte[] key, long integer);

    public abstract Long decr(byte[] key);

    public abstract Long incrBy(byte[] key, long integer);

    public abstract Long incr(byte[] key);

    public abstract Long append(byte[] key, byte[] value);

    public abstract byte[] substr(byte[] key, int start, int end);

    public abstract Long hset(byte[] key, byte[] field, byte[] value);

    public abstract byte[] hget(byte[] key, byte[] field);

    public abstract Long hsetnx(byte[] key, byte[] field, byte[] value);

    public abstract String hmset(byte[] key, Map<byte[], byte[]> hash);

    public abstract List<byte[]> hmget(byte[] key, byte[]... fields);

    public abstract Long hincrBy(byte[] key, byte[] field, long value);

    public abstract Boolean hexists(byte[] key, byte[] field);

    public abstract Long hdel(byte[] key, byte[] field);

    public abstract Long hlen(byte[] key);

    public abstract Set<byte[]> hkeys(byte[] key);

    public abstract Collection<byte[]> hvals(byte[] key);

    public abstract Map<byte[], byte[]> hgetAll(byte[] key);

    public abstract Long rpush(byte[] key, byte[] string);

    public abstract Long lpush(byte[] key, byte[] string);

    public abstract Long llen(byte[] key);

    public abstract List<byte[]> lrange(byte[] key, int start, int end);

    public abstract String ltrim(byte[] key, int start, int end);

    public abstract byte[] lindex(byte[] key, int index);

    public abstract String lset(byte[] key, int index, byte[] value);

    public abstract Long lrem(byte[] key, int count, byte[] value);

    public abstract byte[] lpop(byte[] key);

    public abstract byte[] rpop(byte[] key);

    public abstract Long sadd(byte[] key, byte[] member);

    public abstract Set<byte[]> smembers(byte[] key);

    public abstract Long srem(byte[] key, byte[] member);

    public abstract byte[] spop(byte[] key);

    public abstract Long scard(byte[] key);

    public abstract Boolean sismember(byte[] key, byte[] member);

    public abstract byte[] srandmember(byte[] key);

    public abstract Long zadd(byte[] key, double score, byte[] member);

    public abstract Set<byte[]> zrange(byte[] key, int start, int end);

    public abstract Long zrem(byte[] key, byte[] member);

    public abstract Double zincrby(byte[] key, double score, byte[] member);

    public abstract Long zrank(byte[] key, byte[] member);

    public abstract Long zrevrank(byte[] key, byte[] member);

    public abstract Set<byte[]> zrevrange(byte[] key, int start, int end);

    public abstract Set<Tuple> zrangeWithScores(byte[] key, int start, int end);

    public abstract Set<Tuple> zrevrangeWithScores(byte[] key, int start,
            int end);

    public abstract Long zcard(byte[] key);

    public abstract Double zscore(byte[] key, byte[] member);

    public abstract List<byte[]> sort(byte[] key);

    public abstract List<byte[]> sort(byte[] key,
            SortingParams sortingParameters);

    public abstract Long zcount(byte[] key, double min, double max);

    public abstract Set<byte[]> zrangeByScore(byte[] key, double min, double max);

    public abstract Set<byte[]> zrangeByScore(byte[] key, double min,
            double max, int offset, int count);

    public abstract Set<Tuple> zrangeByScoreWithScores(byte[] key, double min,
            double max);

    public abstract Set<Tuple> zrangeByScoreWithScores(byte[] key, double min,
            double max, int offset, int count);

    public abstract Set<byte[]> zrevrangeByScore(byte[] key, double max,
            double min);

    public abstract Set<byte[]> zrevrangeByScore(byte[] key, double max,
            double min, int offset, int count);

    public abstract Set<Tuple> zrevrangeByScoreWithScores(byte[] key,
            double max, double min);

    public abstract Set<Tuple> zrevrangeByScoreWithScores(byte[] key,
            double max, double min, int offset, int count);

    public abstract Long zremrangeByRank(byte[] key, int start, int end);

    public abstract Long zremrangeByScore(byte[] key, double start, double end);

    public abstract Long linsert(byte[] key, LIST_POSITION where, byte[] pivot,
            byte[] value);

    public abstract List<Object> pipelined(
            ShardedJedisPipeline shardedJedisPipeline);

    public abstract Jedis getShard(byte[] key);

    public abstract Jedis getShard(String key);

    public abstract JedisShardInfo getShardInfo(byte[] key);

    public abstract JedisShardInfo getShardInfo(String key);

    public abstract String getKeyTag(String key);

    public abstract Collection<JedisShardInfo> getAllShardInfo();

    public abstract Collection<Jedis> getAllShards();

}

创建模板实现类使用的redis具体实现类



import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPipeline;
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.BinaryClient.LIST_POSITION;

import com.zxtj.redis.RedisClientTemplate;
import com.zxtj.redis.RedisDataSource;
import common.Logger;

@Repository("redisClientTemplate")
public class RedisClientTemplateImpl implements RedisClientTemplate {

    private static final Logger log = Logger.getLogger(RedisClientTemplateImpl.class);

    @Autowired
    private RedisDataSource   redisDataSource;

    /**
     *<获取jedis数据源> 
     */
    public void disconnect() {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        shardedJedis.disconnect();
    }

    /**
     * <向redis数据库中设置值   key value>
     * @param String key String value
     * @return OK
     */
    public String set(String key, String value) {
        String result = null;

        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.set(key, value);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /**
     * <获取redis中 KEY对应的VALUE>
     * @param key
     * @return value
     */
    public String get(String key) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }

        boolean broken = false;
        try {
            result = shardedJedis.get(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /** 
     * <判断KEY是否存在>
     * @param key
     * @return 存在 TRUE 不存在 FALSE
     */
    public Boolean exists(String key) {
        Boolean result = false;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.exists(key);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /**
     * <返回 key 所储存的值的类型>
     * @param String key
     * @return none (key不存在) string (字符串) list (列表)set (集合) zset (有序集) hash (哈希表)
     */
    public String type(String key) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.type(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#expire(java.lang.String, int)
     */
    public Long expire(String key, int seconds) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.expire(key, seconds);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#expireAt(java.lang.String, long)
     */
    public Long expireAt(String key, long unixTime) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.expireAt(key, unixTime);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#ttl(java.lang.String)
     */
    public Long ttl(String key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.ttl(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#setbit(java.lang.String, long, boolean)
     */
    public boolean setbit(String key, long offset, boolean value) {

        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        boolean result = false;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.setbit(key, offset, value);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getbit(java.lang.String, long)
     */
    public boolean getbit(String key, long offset) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        boolean result = false;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;

        try {
            result = shardedJedis.getbit(key, offset);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#setrange(java.lang.String, long, java.lang.String)
     */
    public long setrange(String key, long offset, String value) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        long result = 0;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.setrange(key, offset, value);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getrange(java.lang.String, long, long)
     */
    public String getrange(String key, long startOffset, long endOffset) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        String result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getrange(key, startOffset, endOffset);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getSet(java.lang.String, java.lang.String)
     */
    public String getSet(String key, String value) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getSet(key, value);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#setnx(java.lang.String, java.lang.String)
     */
    public Long setnx(String key, String value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.setnx(key, value);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#setex(java.lang.String, int, java.lang.String)
     */
    public String setex(String key, int seconds, String value) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.setex(key, seconds, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#decrBy(java.lang.String, long)
     */
    public Long decrBy(String key, long integer) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.decrBy(key, integer);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#decr(java.lang.String)
     */
    public Long decr(String key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.decr(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#incrBy(java.lang.String, long)
     */
    public Long incrBy(String key, long integer) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.incrBy(key, integer);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#incr(java.lang.String)
     */
    public Long incr(String key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.incr(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#append(java.lang.String, java.lang.String)
     */
    public Long append(String key, String value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.append(key, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#substr(java.lang.String, int, int)
     */
    public String substr(String key, int start, int end) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.substr(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hset(java.lang.String, java.lang.String, java.lang.String)
     */
    public Long hset(String key, String field, String value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hset(key, field, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hget(java.lang.String, java.lang.String)
     */
    public String hget(String key, String field) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hget(key, field);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hsetnx(java.lang.String, java.lang.String, java.lang.String)
     */
    public Long hsetnx(String key, String field, String value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hsetnx(key, field, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hmset(java.lang.String, java.util.Map)
     */
    public String hmset(String key, Map<String, String> hash) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hmset(key, hash);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hmget(java.lang.String, java.lang.String)
     */
    public List<String> hmget(String key, String... fields) {
        List<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hmget(key, fields);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hincrBy(java.lang.String, java.lang.String, long)
     */
    public Long hincrBy(String key, String field, long value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hincrBy(key, field, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hexists(java.lang.String, java.lang.String)
     */
    public Boolean hexists(String key, String field) {
        Boolean result = false;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hexists(key, field);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#del(java.lang.String)
     */
    public Long del(String key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.del(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hdel(java.lang.String, java.lang.String)
     */
    public Long hdel(String key, String field) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hdel(key, field);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hlen(java.lang.String)
     */
    public Long hlen(String key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hlen(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hkeys(java.lang.String)
     */
    public Set<String> hkeys(String key) {
        Set<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hkeys(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hvals(java.lang.String)
     */
    public List<String> hvals(String key) {
        List<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hvals(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hgetAll(java.lang.String)
     */
    public Map<String, String> hgetAll(String key) {
        Map<String, String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hgetAll(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    // ================list ====== l表示 list或 left, r表示right====================
    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#rpush(java.lang.String, java.lang.String)
     */
    public Long rpush(String key, String string) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.rpush(key, string);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lpush(java.lang.String, java.lang.String)
     */
    public Long lpush(String key, String string) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lpush(key, string);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#llen(java.lang.String)
     */
    public Long llen(String key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.llen(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lrange(java.lang.String, long, long)
     */
    public List<String> lrange(String key, long start, long end) {
        List<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lrange(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#ltrim(java.lang.String, long, long)
     */
    public String ltrim(String key, long start, long end) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.ltrim(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lindex(java.lang.String, long)
     */
    public String lindex(String key, long index) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lindex(key, index);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lset(java.lang.String, long, java.lang.String)
     */
    public String lset(String key, long index, String value) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lset(key, index, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lrem(java.lang.String, long, java.lang.String)
     */
    public Long lrem(String key, long count, String value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lrem(key, count, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lpop(java.lang.String)
     */
    public String lpop(String key) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lpop(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#rpop(java.lang.String)
     */
    public String rpop(String key) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.rpop(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    //return 1 add a not exist value ,
    //return 0 add a exist value
    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#sadd(java.lang.String, java.lang.String)
     */
    public Long sadd(String key, String member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.sadd(key, member);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#smembers(java.lang.String)
     */
    public Set<String> smembers(String key) {
        Set<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.smembers(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#srem(java.lang.String, java.lang.String)
     */
    public Long srem(String key, String member) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();

        Long result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.srem(key, member);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#spop(java.lang.String)
     */
    public String spop(String key) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        String result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.spop(key);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#scard(java.lang.String)
     */
    public Long scard(String key) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        Long result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.scard(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#sismember(java.lang.String, java.lang.String)
     */
    public Boolean sismember(String key, String member) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        Boolean result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.sismember(key, member);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#srandmember(java.lang.String)
     */
    public String srandmember(String key) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        String result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.srandmember(key);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zadd(java.lang.String, double, java.lang.String)
     */
    public Long zadd(String key, double score, String member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.zadd(key, score, member);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrange(java.lang.String, int, int)
     */
    public Set<String> zrange(String key, int start, int end) {
        Set<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.zrange(key, start, end);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrem(java.lang.String, java.lang.String)
     */
    public Long zrem(String key, String member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.zrem(key, member);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zincrby(java.lang.String, double, java.lang.String)
     */
    public Double zincrby(String key, double score, String member) {
        Double result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zincrby(key, score, member);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrank(java.lang.String, java.lang.String)
     */
    public Long zrank(String key, String member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrank(key, member);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrank(java.lang.String, java.lang.String)
     */
    public Long zrevrank(String key, String member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrank(key, member);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrange(java.lang.String, int, int)
     */
    public Set<String> zrevrange(String key, int start, int end) {
        Set<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrange(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeWithScores(java.lang.String, int, int)
     */
    public Set<Tuple> zrangeWithScores(String key, int start, int end) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeWithScores(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeWithScores(java.lang.String, int, int)
     */
    public Set<Tuple> zrevrangeWithScores(String key, int start, int end) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeWithScores(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zcard(java.lang.String)
     */
    public Long zcard(String key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zcard(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zscore(java.lang.String, java.lang.String)
     */
    public Double zscore(String key, String member) {
        Double result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zscore(key, member);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#sort(java.lang.String)
     */
    public List<String> sort(String key) {
        List<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.sort(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#sort(java.lang.String, redis.clients.jedis.SortingParams)
     */
    public List<String> sort(String key, SortingParams sortingParameters) {
        List<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.sort(key, sortingParameters);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zcount(java.lang.String, double, double)
     */
    public Long zcount(String key, double min, double max) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zcount(key, min, max);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeByScore(java.lang.String, double, double)
     */
    public Set<String> zrangeByScore(String key, double min, double max) {
        Set<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeByScore(key, min, max);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeByScore(java.lang.String, double, double)
     */
    public Set<String> zrevrangeByScore(String key, double max, double min) {
        Set<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeByScore(key, max, min);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeByScore(java.lang.String, double, double, int, int)
     */
    public Set<String> zrangeByScore(String key, double min, double max, int offset, int count) {
        Set<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeByScore(key, min, max, offset, count);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeByScore(java.lang.String, double, double, int, int)
     */
    public Set<String> zrevrangeByScore(String key, double max, double min, int offset, int count) {
        Set<String> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeByScore(key, max, min, offset, count);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeByScoreWithScores(java.lang.String, double, double)
     */
    public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeByScoreWithScores(key, min, max);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeByScoreWithScores(java.lang.String, double, double)
     */
    public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeByScoreWithScores(key, max, min);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeByScoreWithScores(java.lang.String, double, double, int, int)
     */
    public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeByScoreWithScores(key, min, max, offset, count);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeByScoreWithScores(java.lang.String, double, double, int, int)
     */
    public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeByScoreWithScores(key, max, min, offset, count);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zremrangeByRank(java.lang.String, int, int)
     */
    public Long zremrangeByRank(String key, int start, int end) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zremrangeByRank(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zremrangeByScore(java.lang.String, double, double)
     */
    public Long zremrangeByScore(String key, double start, double end) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zremrangeByScore(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#linsert(java.lang.String, redis.clients.jedis.BinaryClient.LIST_POSITION, java.lang.String, java.lang.String)
     */
    public Long linsert(String key, LIST_POSITION where, String pivot, String value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.linsert(key, where, pivot, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#set(byte[], byte[])
     */
    public String set(byte[] key, byte[] value) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.set(key, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#get(byte[])
     */
    public byte[] get(byte[] key) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.get(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#exists(byte[])
     */
    public Boolean exists(byte[] key) {
        Boolean result = false;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.exists(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#type(byte[])
     */
    public String type(byte[] key) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.type(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#expire(byte[], int)
     */
    public Long expire(byte[] key, int seconds) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.expire(key, seconds);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#expireAt(byte[], long)
     */
    public Long expireAt(byte[] key, long unixTime) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.expireAt(key, unixTime);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#ttl(byte[])
     */
    public Long ttl(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.ttl(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getSet(byte[], byte[])
     */
    public byte[] getSet(byte[] key, byte[] value) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.getSet(key, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#setnx(byte[], byte[])
     */
    public Long setnx(byte[] key, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.setnx(key, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#setex(byte[], int, byte[])
     */
    public String setex(byte[] key, int seconds, byte[] value) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.setex(key, seconds, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#decrBy(byte[], long)
     */
    public Long decrBy(byte[] key, long integer) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.decrBy(key, integer);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#decr(byte[])
     */
    public Long decr(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.decr(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#incrBy(byte[], long)
     */
    public Long incrBy(byte[] key, long integer) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.incrBy(key, integer);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#incr(byte[])
     */
    public Long incr(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.incr(key);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#append(byte[], byte[])
     */
    public Long append(byte[] key, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.append(key, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#substr(byte[], int, int)
     */
    public byte[] substr(byte[] key, int start, int end) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.substr(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hset(byte[], byte[], byte[])
     */
    public Long hset(byte[] key, byte[] field, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hset(key, field, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hget(byte[], byte[])
     */
    public byte[] hget(byte[] key, byte[] field) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hget(key, field);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hsetnx(byte[], byte[], byte[])
     */
    public Long hsetnx(byte[] key, byte[] field, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hsetnx(key, field, value);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hmset(byte[], java.util.Map)
     */
    public String hmset(byte[] key, Map<byte[], byte[]> hash) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hmset(key, hash);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hmget(byte[], byte)
     */
    public List<byte[]> hmget(byte[] key, byte[]... fields) {
        List<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hmget(key, fields);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hincrBy(byte[], byte[], long)
     */
    public Long hincrBy(byte[] key, byte[] field, long value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hincrBy(key, field, value);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hexists(byte[], byte[])
     */
    public Boolean hexists(byte[] key, byte[] field) {
        Boolean result = false;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hexists(key, field);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hdel(byte[], byte[])
     */
    public Long hdel(byte[] key, byte[] field) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hdel(key, field);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hlen(byte[])
     */
    public Long hlen(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hlen(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hkeys(byte[])
     */
    public Set<byte[]> hkeys(byte[] key) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hkeys(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hvals(byte[])
     */
    public Collection<byte[]> hvals(byte[] key) {
        Collection<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hvals(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#hgetAll(byte[])
     */
    public Map<byte[], byte[]> hgetAll(byte[] key) {
        Map<byte[], byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.hgetAll(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#rpush(byte[], byte[])
     */
    public Long rpush(byte[] key, byte[] string) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.rpush(key, string);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lpush(byte[], byte[])
     */
    public Long lpush(byte[] key, byte[] string) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.lpush(key, string);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#llen(byte[])
     */
    public Long llen(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.llen(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lrange(byte[], int, int)
     */
    public List<byte[]> lrange(byte[] key, int start, int end) {
        List<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.lrange(key, start, end);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#ltrim(byte[], int, int)
     */
    public String ltrim(byte[] key, int start, int end) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.ltrim(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lindex(byte[], int)
     */
    public byte[] lindex(byte[] key, int index) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.lindex(key, index);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lset(byte[], int, byte[])
     */
    public String lset(byte[] key, int index, byte[] value) {
        String result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.lset(key, index, value);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lrem(byte[], int, byte[])
     */
    public Long lrem(byte[] key, int count, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.lrem(key, count, value);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#lpop(byte[])
     */
    public byte[] lpop(byte[] key) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.lpop(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#rpop(byte[])
     */
    public byte[] rpop(byte[] key) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.rpop(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#sadd(byte[], byte[])
     */
    public Long sadd(byte[] key, byte[] member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.sadd(key, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#smembers(byte[])
     */
    public Set<byte[]> smembers(byte[] key) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.smembers(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#srem(byte[], byte[])
     */
    public Long srem(byte[] key, byte[] member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.srem(key, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#spop(byte[])
     */
    public byte[] spop(byte[] key) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.spop(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#scard(byte[])
     */
    public Long scard(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.scard(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#sismember(byte[], byte[])
     */
    public Boolean sismember(byte[] key, byte[] member) {
        Boolean result = false;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.sismember(key, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#srandmember(byte[])
     */
    public byte[] srandmember(byte[] key) {
        byte[] result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.srandmember(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zadd(byte[], double, byte[])
     */
    public Long zadd(byte[] key, double score, byte[] member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zadd(key, score, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrange(byte[], int, int)
     */
    public Set<byte[]> zrange(byte[] key, int start, int end) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrange(key, start, end);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrem(byte[], byte[])
     */
    public Long zrem(byte[] key, byte[] member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrem(key, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zincrby(byte[], double, byte[])
     */
    public Double zincrby(byte[] key, double score, byte[] member) {
        Double result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zincrby(key, score, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrank(byte[], byte[])
     */
    public Long zrank(byte[] key, byte[] member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrank(key, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrank(byte[], byte[])
     */
    public Long zrevrank(byte[] key, byte[] member) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrank(key, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrange(byte[], int, int)
     */
    public Set<byte[]> zrevrange(byte[] key, int start, int end) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrange(key, start, end);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeWithScores(byte[], int, int)
     */
    public Set<Tuple> zrangeWithScores(byte[] key, int start, int end) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeWithScores(key, start, end);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeWithScores(byte[], int, int)
     */
    public Set<Tuple> zrevrangeWithScores(byte[] key, int start, int end) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeWithScores(key, start, end);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zcard(byte[])
     */
    public Long zcard(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zcard(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zscore(byte[], byte[])
     */
    public Double zscore(byte[] key, byte[] member) {
        Double result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zscore(key, member);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#sort(byte[])
     */
    public List<byte[]> sort(byte[] key) {
        List<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.sort(key);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#sort(byte[], redis.clients.jedis.SortingParams)
     */
    public List<byte[]> sort(byte[] key, SortingParams sortingParameters) {
        List<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.sort(key, sortingParameters);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zcount(byte[], double, double)
     */
    public Long zcount(byte[] key, double min, double max) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zcount(key, min, max);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeByScore(byte[], double, double)
     */
    public Set<byte[]> zrangeByScore(byte[] key, double min, double max) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeByScore(key, min, max);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeByScore(byte[], double, double, int, int)
     */
    public Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset, int count) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeByScore(key, min, max, offset, count);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeByScoreWithScores(byte[], double, double)
     */
    public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeByScoreWithScores(key, min, max);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrangeByScoreWithScores(byte[], double, double, int, int)
     */
    public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max, int offset, int count) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrangeByScoreWithScores(key, min, max, offset, count);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeByScore(byte[], double, double)
     */
    public Set<byte[]> zrevrangeByScore(byte[] key, double max, double min) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeByScore(key, max, min);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeByScore(byte[], double, double, int, int)
     */
    public Set<byte[]> zrevrangeByScore(byte[] key, double max, double min, int offset, int count) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeByScore(key, max, min, offset, count);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeByScoreWithScores(byte[], double, double)
     */
    public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeByScoreWithScores(key, max, min);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zrevrangeByScoreWithScores(byte[], double, double, int, int)
     */
    public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min, int offset, int count) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zrevrangeByScoreWithScores(key, max, min, offset, count);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zremrangeByRank(byte[], int, int)
     */
    public Long zremrangeByRank(byte[] key, int start, int end) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zremrangeByRank(key, start, end);

        } catch (Exception e) {

            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#zremrangeByScore(byte[], double, double)
     */
    public Long zremrangeByScore(byte[] key, double start, double end) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.zremrangeByScore(key, start, end);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#linsert(byte[], redis.clients.jedis.BinaryClient.LIST_POSITION, byte[], byte[])
     */
    public Long linsert(byte[] key, LIST_POSITION where, byte[] pivot, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {

            result = shardedJedis.linsert(key, where, pivot, value);

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#pipelined(redis.clients.jedis.ShardedJedisPipeline)
     */
    public List<Object> pipelined(ShardedJedisPipeline shardedJedisPipeline) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        List<Object> result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.pipelined(shardedJedisPipeline);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getShard(byte[])
     */
    public Jedis getShard(byte[] key) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        Jedis result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getShard(key);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getShard(java.lang.String)
     */
    public Jedis getShard(String key) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        Jedis result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getShard(key);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getShardInfo(byte[])
     */
    public JedisShardInfo getShardInfo(byte[] key) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        JedisShardInfo result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getShardInfo(key);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getShardInfo(java.lang.String)
     */
    public JedisShardInfo getShardInfo(String key) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        JedisShardInfo result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getShardInfo(key);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getKeyTag(java.lang.String)
     */
    public String getKeyTag(String key) {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        String result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getKeyTag(key);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getAllShardInfo()
     */
    public Collection<JedisShardInfo> getAllShardInfo() {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        Collection<JedisShardInfo> result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getAllShardInfo();

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

    /* (non-Javadoc)
     * @see com.zxtj.redis.impl.RedisClientTemplate#getAllShards()
     */
    public Collection<Jedis> getAllShards() {
        ShardedJedis shardedJedis = redisDataSource.getRedisClient();
        Collection<Jedis> result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getAllShards();

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            broken = true;
        } finally {
            redisDataSource.returnResource(shardedJedis, broken);
        }
        return result;
    }

}

测试类

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.zxtj.redis.impl.RedisClientTemplateImpl;

public class TestRedies {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("classpath:redisContext.xml");
        RedisClientTemplateImpl redisClient = (RedisClientTemplateImpl) ac.getBean("redisClientTemplate");
        //String value = redisClient.get("100");
        //Boolean value = redisClient.exists("100");
        String value = redisClient.set("yaya", "123156644");
        System.out.println("获取到的值:"+value);
    }
}
版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

重温redis--redis在springmvc下的使用

redis       Redis是一个开源,先进的key-value存储,并用于构建高性能,可扩展的Web应用程序的完美解决方案。       Redis从它的许多竞争继承来的三个主要特点: ...

Spring中使用redis

redis的知识:官网 1,利用spring-data-redis整合 项目使用的pom.xml: project xmlns="http://maven.apache.org/POM/4.0...

程序员升职加薪指南!还缺一个“证”!

CSDN出品,立即查看!

使用Spring-data进行Redis操作

使用Spring-data进行Redis操作 Redis相信大家都听说过,它是一个开源的key-value缓存数据库,有很多Java的客户端支持,比较有名的有Jedis,JRedis...

spring 整合 redis,以及spring的RedisTemplate如何使用

需要的jar包 spring-data-redis-1.6.2.RELEASE.jar jedis-2.7.2.jar(依赖 commons-pool2-2.3.jar) commons-po...

java之redis篇(spring-data-redis整合)

http://www.cnblogs.com/tankaixiong/p/3660075.html   redis的知识:官网 1,利用spring-data-redis整合 项目使用的pom....

深入理解SpringRedis的使用

SpringRedis基本使用 关于spring redis框架的使用,网上的例子很多很多。但是在自己最近一段时间的使用中,发现这些教程都是入门教程,包括很多的使用方法,与spring redis丰富...

spring 结合 Redis 例子,简单入门例子

好了费话不多说了,介绍下spring 结合redis是怎么操作数据的 这里我用了maven管理,由于简单嘛,依赖下包就行了..不用单独去依赖包,成了我的习惯 好了,下面是pom的代码 ...

java springMVC里搭建redis

Redis介绍     Redis本质上一个Key/Value数据库,与Memcached类似的NoSQL型数据库,但是他的数据可以持久化的保存在磁盘上,解决了服务重启后数据不丢失的问题,他的值可以是...

Redis 在 Java 中的使用

一、下载jar包   https://github.com/xetorthio/jedis/downloads 学习参考内容 : http://blog.nosqlfan.com/html/35...

spring-java项目中连接redis数据库

最近由于项目需要,要从redis数据库中查询一些数据,还没有了解过redis,只好硬着头皮上阵,记录一下连接过程: 1、需要导入两个jar包:jedis.jar,spring-data-redis.j...
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)