package com.ywt.alipaympapi.core.redis;

import org.springframework.stereotype.Service;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPool;

import javax.annotation.Resource;

/**
 * Created by huangguoping.
 */
@Service
public class RedisCacheManager {
    @Resource(name = "jedisPool")
    private ShardedJedisPool pool;

    public ShardedJedis getJedis() {
        ShardedJedis jedis = pool.getResource();
        return jedis;
    }

    public void returnResource(ShardedJedis jedis) {
        try {
            pool.returnResource(jedis);
        }catch (Exception e){
            //e.printStackTrace();
        }
    }
}
