Search in sources :

Example 1 with ValueOperations

use of org.springframework.data.redis.core.ValueOperations 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");
}
Also used : RedisTemplate(org.springframework.data.redis.core.RedisTemplate) ValueOperations(org.springframework.data.redis.core.ValueOperations)

Example 2 with ValueOperations

use of org.springframework.data.redis.core.ValueOperations 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);
}
Also used : RedisTemplate(org.springframework.data.redis.core.RedisTemplate) ValueOperations(org.springframework.data.redis.core.ValueOperations)

Aggregations

RedisTemplate (org.springframework.data.redis.core.RedisTemplate)2 ValueOperations (org.springframework.data.redis.core.ValueOperations)2