com.github.ibole.infrastructure.cache.redis.RedisTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infrastructure-all Show documentation
Show all versions of infrastructure-all Show documentation
The all in one project of ibole infrastructure
The newest version!
package com.github.ibole.infrastructure.cache.redis;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
/*********************************************************************************************
* .
*
*
* Copyright 2016, iBole Inc. All rights reserved.
*
*
.
*
*********************************************************************************************/
public abstract class RedisTemplate {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/*
* Execute callback operation.
*
* @param params parameters to the call
*/
protected T execute(RedisCallback callback, Object... args) {
Jedis jedis = getRedis();
try {
return callback.call(jedis, args);
} catch (Exception e) {
logger.error("Execute callback failed!", e);
} finally {
if (jedis != null) {
closeRedis(jedis);
}
}
return null;
}
protected abstract Jedis getRedis();
protected abstract void closeRedis(Jedis jedis);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy