use of org.springframework.data.redis.core.RedisTemplate in project camel by apache.
the class RedisConfiguration method createDefaultTemplate.
private RedisTemplate createDefaultTemplate() {
redisTemplate = new RedisTemplate();
redisTemplate.setDefaultSerializer(getSerializer());
redisTemplate.setConnectionFactory(getConnectionFactory());
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
use of org.springframework.data.redis.core.RedisTemplate in project camel by apache.
the class RedisConsumerIntegrationTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(CONNECTION_FACTORY);
redisTemplate.afterPropertiesSet();
registry.bind("redisTemplate", redisTemplate);
registry.bind("listenerContainer", LISTENER_CONTAINER);
return registry;
}
use of org.springframework.data.redis.core.RedisTemplate in project spring-boot-mybatis-with-redis by Lovelcp.
the class RedisCache method putObject.
/**
* Put query result to redis
*
* @param key
* @param value
*/
@Override
@SuppressWarnings("unchecked")
public void putObject(Object key, Object value) {
RedisTemplate redisTemplate = getRedisTemplate();
ValueOperations opsForValue = redisTemplate.opsForValue();
opsForValue.set(key, value, EXPIRE_TIME_IN_MINUTES, TimeUnit.MINUTES);
logger.debug("Put query result to redis");
}
use of org.springframework.data.redis.core.RedisTemplate in project spring-boot-mybatis-with-redis by Lovelcp.
the class RedisCache method clear.
/**
* Clears this cache instance
*/
@Override
public void clear() {
RedisTemplate redisTemplate = getRedisTemplate();
redisTemplate.execute((RedisCallback) connection -> {
connection.flushDb();
return null;
});
logger.debug("Clear all the cached query result from redis");
}
use of org.springframework.data.redis.core.RedisTemplate in project spring-boot-mybatis-with-redis by Lovelcp.
the class RedisCache method getObject.
/**
* Get cached query result from redis
*
* @param key
* @return
*/
@Override
public Object getObject(Object key) {
RedisTemplate redisTemplate = getRedisTemplate();
ValueOperations opsForValue = redisTemplate.opsForValue();
logger.debug("Get cached query result from redis");
return opsForValue.get(key);
}
Aggregations