package com.elab.redis.spring.data;

import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * redisTemplate 装饰器
 *
 * @author ： liukx
 * @time ： 2020/7/8 - 16:50
 */
public class RedisTemplateDecorator<String, CacheValueModel> extends RedisTemplate<String, CacheValueModel> {

    @Override
    public <T> T execute(RedisCallback<T> action, boolean exposeConnection, boolean pipeline) {
        try {
            return super.execute(action, exposeConnection, pipeline);
        } catch (Exception e) {
            logger.error("缓存执行失败", e);
        }
        return null;
    }

    @Override
    protected <T> T postProcessResult(T result, RedisConnection conn, boolean existingConnection) {
        return super.postProcessResult(result, conn, existingConnection);
    }
}
