package com.elab.cache.redis;

import com.elab.cache.ICacheClient;
import com.sohu.tv.builder.RedisStandaloneBuilder;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * 操作redis单机
 *
 * @author Liukx
 * @create 2017-05-17 14:06
 * @email liukx@elab-plus.com
 **/
public class RedisStandaloneClient extends BaseRedisOperation implements ICacheClient {

    private RedisStandaloneBuilder redisBuilder;

    private JedisPool jedisPool;

    public void setRedisBuilder(RedisStandaloneBuilder redisBuilder) {
        this.redisBuilder = redisBuilder;
    }

    public void init() {
        jedisPool = redisBuilder.build();
    }

    @Override
    public ICacheClient getCacheClient() {
        return this;
    }

    @Override
    public Jedis getResource() {
        return jedisPool.getResource();
    }
}
