1. 程式人生 > >Redis操作工具類

Redis操作工具類

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.avant.qyx.manage.redis;


import com.avant.qyx.manage.util.InfoUtil;
import com.avant.qyx.manage.util.LogUtil;
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.BinaryClient.LIST_POSITION;
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;


/**
 *
 * @author dizhang
 */
@Repository
public class RedisService {


    @Autowired
    private RedisSource RedisSource;


    public void disconnect() {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        shardedJedis.disconnect();
    }


    /**
     * 設定單個值
     *
     * @param key
     * @param value
     * @return
     */
    public String set(String key, String value) {
        String result = null;


        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.set(key, value);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    /**
     * 獲取單個值
     *
     * @param key
     * @return
     */
    public String get(String key) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }


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


        } catch (Exception e) {
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    /**
     * 判斷是否存在這個key
     *
     * @param key
     * @return 存在返回true 否則返回false
     */
    public Boolean exists(String key) {
        Boolean result = false;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.exists(key);
        } catch (Exception e) {
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String type(String key) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.type(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    /**
     * 在某段時間後失效(秒為單位)
     *
     * @param key
     * @param unixTime
     * @return
     */
    public Long expire(String key, int seconds) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.expire(key, seconds);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    /**
     * 在某個時間點失效
     *
     * @param key
     * @param unixTime
     * @return
     */
    public Long expireAt(String key, long unixTime) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.expireAt(key, unixTime);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    /**
     * 返回key的剩餘過期時間。
     *
     * @param key
     * @return
     */
    public Long ttl(String key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.ttl(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public boolean setbit(String key, long offset, boolean value) {


        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        boolean result = false;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.setbit(key, offset, value);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public boolean getbit(String key, long offset) {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        boolean result = false;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;


        try {
            result = shardedJedis.getbit(key, offset);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public long setrange(String key, long offset, String value) {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        long result = 0;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.setrange(key, offset, value);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String getrange(String key, long startOffset, long endOffset) {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        String result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getrange(key, startOffset, endOffset);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String getSet(String key, String value) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.getSet(key, value);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long setnx(String key, String value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.setnx(key, value);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String setex(String key, int seconds, String value) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.setex(key, seconds, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long decrBy(String key, long integer) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.decrBy(key, integer);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long decr(String key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.decr(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long incrBy(String key, long integer) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.incrBy(key, integer);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long incr(String key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.incr(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long append(String key, String value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.append(key, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String substr(String key, int start, int end) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.substr(key, start, end);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hset(String key, String field, String value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hset(key, field, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String hget(String key, String field) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hget(key, field);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hsetnx(String key, String field, String value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hsetnx(key, field, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    /**
     * hash型別插入
     *
     * @param key
     * @param hash
     * @return
     */
    public String hmset(String key, Map<String, String> hash) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hmset(key, hash);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    /**
     * hash型別插入
     *
     * @param key 
     * @param fields 需要查詢的列
     * @return
     */
    public List<String> hmget(String key, String... fields) {
        List<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hmget(key, fields);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hincrBy(String key, String field, long value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hincrBy(key, field, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Boolean hexists(String key, String field) {
        Boolean result = false;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hexists(key, field);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    
    /**
     * 根據key來刪除Redis裡面的資料
     * @param key
     * @return 
     */
    public Long del(String key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.del(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hdel(String key, String field) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hdel(key, field);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hlen(String key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hlen(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<String> hkeys(String key) {
        Set<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hkeys(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public List<String> hvals(String key) {
        List<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hvals(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Map<String, String> hgetAll(String key) {
        Map<String, String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.hgetAll(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    // ================list ====== l表示 list或 left, r表示right====================
    public Long rpush(String key, String string) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.rpush(key, string);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long lpush(String key, String string) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lpush(key, string);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long llen(String key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.llen(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public List<String> lrange(String key, long start, long end) {
        List<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lrange(key, start, end);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String ltrim(String key, long start, long end) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.ltrim(key, start, end);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String lindex(String key, long index) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lindex(key, index);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String lset(String key, long index, String value) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lset(key, index, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long lrem(String key, long count, String value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lrem(key, count, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String lpop(String key) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.lpop(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String rpop(String key) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.rpop(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    //return 1 add a not exist value ,
    //return 0 add a exist value
    public Long sadd(String key, String member) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.sadd(key, member);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<String> smembers(String key) {
        Set<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.smembers(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long srem(String key, String member) {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();


        Long result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.srem(key, member);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String spop(String key) {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        String result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.spop(key);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long scard(String key) {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        Long result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.scard(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Boolean sismember(String key, String member) {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        Boolean result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.sismember(key, member);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String srandmember(String key) {
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        String result = null;
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.srandmember(key);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long zadd(String key, double score, String member) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.zadd(key, score, member);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<String> zrange(String key, int start, int end) {
        Set<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.zrange(key, start, end);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long zrem(String key, String member) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {
            result = shardedJedis.zrem(key, member);
        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Double zincrby(String key, double score, String member) {
        Double result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long zrank(String key, String member) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.zrank(key, member);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long zrevrank(String key, String member) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.zrevrank(key, member);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<String> zrevrange(String key, int start, int end) {
        Set<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<Tuple> zrangeWithScores(String key, int start, int end) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<Tuple> zrevrangeWithScores(String key, int start, int end) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long zcard(String key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.zcard(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Double zscore(String key, String member) {
        Double result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.zscore(key, member);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public List<String> sort(String key) {
        List<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.sort(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public List<String> sort(String key, SortingParams sortingParameters) {
        List<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.sort(key, sortingParameters);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long zcount(String key, double min, double max) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<String> zrangeByScore(String key, double min, double max) {
        Set<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<String> zrevrangeByScore(String key, double max, double min) {
        Set<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<String> zrangeByScore(String key, double min, double max, int offset, int count) {
        Set<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<String> zrevrangeByScore(String key, double max, double min, int offset, int count) {
        Set<String> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) {
        Set<Tuple> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long zremrangeByRank(String key, int start, int end) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long zremrangeByScore(String key, double start, double end) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long linsert(String key, LIST_POSITION where, String pivot, String value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String set(byte[] key, byte[] value) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.set(key, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public byte[] get(byte[] key) {
        byte[] result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.get(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Boolean exists(byte[] key) {
        Boolean result = false;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.exists(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String type(byte[] key) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.type(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long expire(byte[] key, int seconds) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.expire(key, seconds);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long expireAt(byte[] key, long unixTime) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.expireAt(key, unixTime);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long ttl(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.ttl(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public byte[] getSet(byte[] key, byte[] value) {
        byte[] result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.getSet(key, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long setnx(byte[] key, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.setnx(key, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String setex(byte[] key, int seconds, byte[] value) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long decrBy(byte[] key, long integer) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.decrBy(key, integer);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long decr(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.decr(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long incrBy(byte[] key, long integer) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.incrBy(key, integer);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long incr(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.incr(key);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long append(byte[] key, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.append(key, value);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public byte[] substr(byte[] key, int start, int end) {
        byte[] result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hset(byte[] key, byte[] field, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public byte[] hget(byte[] key, byte[] field) {
        byte[] result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hget(key, field);


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hsetnx(byte[] key, byte[] field, byte[] value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String hmset(byte[] key, Map<byte[], byte[]> hash) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hmset(key, hash);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public List<byte[]> hmget(byte[] key, byte[]... fields) {
        List<byte[]> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hmget(key, fields);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hincrBy(byte[] key, byte[] field, long value) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Boolean hexists(byte[] key, byte[] field) {
        Boolean result = false;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hexists(key, field);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hdel(byte[] key, byte[] field) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hdel(key, field);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long hlen(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hlen(key);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Set<byte[]> hkeys(byte[] key) {
        Set<byte[]> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hkeys(key);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Collection<byte[]> hvals(byte[] key) {
        Collection<byte[]> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hvals(key);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Map<byte[], byte[]> hgetAll(byte[] key) {
        Map<byte[], byte[]> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.hgetAll(key);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long rpush(byte[] key, byte[] string) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.rpush(key, string);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long lpush(byte[] key, byte[] string) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.lpush(key, string);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public Long llen(byte[] key) {
        Long result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.llen(key);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public List<byte[]> lrange(byte[] key, int start, int end) {
        List<byte[]> result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String ltrim(byte[] key, int start, int end) {
        String result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


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


        } catch (Exception e) {
            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public byte[] lindex(byte[] key, int index) {
        byte[] result = null;
        ShardedJedis shardedJedis = RedisSource.getRedisClient();
        if (shardedJedis == null) {
            return result;
        }
        boolean broken = false;
        try {


            result = shardedJedis.lindex(key, index);


        } catch (Exception e) {


            LogUtil.i(InfoUtil.getLineInfo(), "RedisService", e);
            broken = true;
        } finally {
            RedisSource.returnResource(shardedJedis, broken);
        }
        return result;
    }


    public String lset(byte[] key, int index, byte[]