Java Code Examples for org.springframework.data.redis.core.RedisTemplate#opsForValue()

The following examples show how to use org.springframework.data.redis.core.RedisTemplate#opsForValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisCache.java    From yfshop with Apache License 2.0 5 votes vote down vote up
/**
 * Put query result to redis
 *
 * @param key
 * @param value
 */
@Override
public void putObject(Object key, Object value) {
    try {
        RedisTemplate redisTemplate = getRedisTemplate();
        ValueOperations opsForValue = redisTemplate.opsForValue();
        opsForValue.set(key, value, EXPIRE_TIME_IN_MINUTES, TimeUnit.MINUTES);
        logger.debug("Put query result to redis");
    } catch (Throwable t) {
        logger.error("Redis put failed", t);
    }
}
 
Example 2
Source File: RedisCache.java    From poseidon with Apache License 2.0 5 votes vote down vote up
/**
 * Get cached query result from redis
 * @param key
 * @return
 */
@Override
public Object getObject(Object key) {
	try {
		RedisTemplate redisTemplate = getRedisTemplate();
		ValueOperations opsForValue = redisTemplate.opsForValue();
		logger.debug("Get cached query result from redis");
		return opsForValue.get(key);
	}
	catch (Throwable t) {
		logger.error("Redis get failed, fail over to db", t);
		return null;
	}
}
 
Example 3
Source File: RedisCache.java    From poseidon with Apache License 2.0 5 votes vote down vote up
/**
 * Put query result to redis
 * @param key
 * @param value
 */
@Override
@SuppressWarnings("unchecked")
public void putObject(Object key, Object value) {
	try {
		RedisTemplate redisTemplate = getRedisTemplate();
		ValueOperations opsForValue = redisTemplate.opsForValue();
		opsForValue.set(key, value, EXPIRE_TIME_IN_MINUTES, TimeUnit.MINUTES);
		logger.debug("Put query result to redis");
	}
	catch (Throwable t) {
		logger.error("Redis put failed", t);
	}
}
 
Example 4
Source File: RedisCache.java    From poseidon with Apache License 2.0 5 votes vote down vote up
/**
 * Get cached query result from redis
 * @param key
 * @return
 */
@Override
public Object getObject(Object key) {
	try {
		RedisTemplate redisTemplate = getRedisTemplate();
		ValueOperations opsForValue = redisTemplate.opsForValue();
		logger.debug("Get cached query result from redis");
		return opsForValue.get(key);
	}
	catch (Throwable t) {
		logger.error("Redis get failed, fail over to db", t);
		return null;
	}
}
 
Example 5
Source File: RedisCache.java    From poseidon with Apache License 2.0 5 votes vote down vote up
/**
 * Put query result to redis
 * @param key
 * @param value
 */
@Override
@SuppressWarnings("unchecked")
public void putObject(Object key, Object value) {
	try {
		RedisTemplate redisTemplate = getRedisTemplate();
		ValueOperations opsForValue = redisTemplate.opsForValue();
		opsForValue.set(key, value, EXPIRE_TIME_IN_MINUTES, TimeUnit.MINUTES);
		logger.debug("Put query result to redis");
	}
	catch (Throwable t) {
		logger.error("Redis put failed", t);
	}
}
 
Example 6
Source File: RedisCache.java    From poseidon with Apache License 2.0 5 votes vote down vote up
/**
 * Get cached query result from redis
 * @param key
 * @return
 */
@Override
public Object getObject(Object key) {
	try {
		RedisTemplate redisTemplate = getRedisTemplate();
		ValueOperations opsForValue = redisTemplate.opsForValue();
		logger.debug("Get cached query result from redis");
		return opsForValue.get(key);
	}
	catch (Throwable t) {
		logger.error("Redis get failed, fail over to db", t);
		return null;
	}
}
 
Example 7
Source File: RedisCache.java    From poseidon with Apache License 2.0 5 votes vote down vote up
/**
 * Put query result to redis
 * @param key
 * @param value
 */
@Override
@SuppressWarnings("unchecked")
public void putObject(Object key, Object value) {
	try {
		RedisTemplate redisTemplate = getRedisTemplate();
		ValueOperations opsForValue = redisTemplate.opsForValue();
		opsForValue.set(key, value, EXPIRE_TIME_IN_MINUTES, TimeUnit.MINUTES);
		logger.debug("Put query result to redis");
	}
	catch (Throwable t) {
		logger.error("Redis put failed", t);
	}
}
 
Example 8
Source File: TestController.java    From spring_boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/redisSelectTwo")
public String redisSelectTwo(){
    RedisTemplate template = RedisUtil.getSelect_1();
    ValueOperations ops = template.opsForValue();
    ops.set("test","1");
    return "success";
}
 
Example 9
Source File: RedisCache.java    From poseidon with Apache License 2.0 5 votes vote down vote up
/**
 * Put query result to redis
 * @param key
 * @param value
 */
@Override
@SuppressWarnings("unchecked")
public void putObject(Object key, Object value) {
	try {
		RedisTemplate redisTemplate = getRedisTemplate();
		ValueOperations opsForValue = redisTemplate.opsForValue();
		opsForValue.set(key, value, EXPIRE_TIME_IN_MINUTES, TimeUnit.MINUTES);
		logger.debug("Put query result to redis");
	}
	catch (Throwable t) {
		logger.error("Redis put failed", t);
	}
}
 
Example 10
Source File: RedisCache.java    From dbys with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get cached query result from redis
 *
 * @param key
 * @return
 */
@Override
public Object getObject(Object key) {
    try {
        RedisTemplate redisTemplate = getRedisTemplate();
        ValueOperations opsForValue = redisTemplate.opsForValue();
        logger.debug("Get cached query result from redis");
        return opsForValue.get(key.toString());
    } catch (Throwable t) {
        logger.error("Redis get failed, fail over to db", t);
        return null;
    }
}
 
Example 11
Source File: TestController.java    From spring_boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/redisSelectOne")
public String redisSelectOne(){
    RedisTemplate template = RedisUtil.getSelect_0();
    ValueOperations ops = template.opsForValue();
    ops.set("test","0");
    return "success";
}
 
Example 12
Source File: RedisCache.java    From poseidon with Apache License 2.0 5 votes vote down vote up
/**
 * Get cached query result from redis
 * @param key
 * @return
 */
@Override
public Object getObject(Object key) {
	try {
		RedisTemplate redisTemplate = getRedisTemplate();
		ValueOperations opsForValue = redisTemplate.opsForValue();
		logger.debug("Get cached query result from redis");
		return opsForValue.get(key);
	}
	catch (Throwable t) {
		logger.error("Redis get failed, fail over to db", t);
		return null;
	}
}
 
Example 13
Source File: RedisCache.java    From yfshop with Apache License 2.0 5 votes vote down vote up
/**
     * Get cached query result from redis
     *
     * @param key
     * @return
     */
    @Override
    public Object getObject(Object key) {
        try {
            RedisTemplate redisTemplate = getRedisTemplate();
            ValueOperations opsForValue = redisTemplate.opsForValue();
            logger.debug("Get cached query result from redis");
//            System.out.println("****" + opsForValue.get(key).toString());
            return opsForValue.get(key);
        } catch (Throwable t) {
            logger.error("Redis get failed, fail over to db", t);
            return null;
        }
    }
 
Example 14
Source File: RedisSessionDao.java    From ssm with Apache License 2.0 4 votes vote down vote up
public RedisSessionDao(RedisTemplate redisTemplate) {
	this.redisTemplate = redisTemplate;
	this.valueOperations = redisTemplate.opsForValue();
}
 
Example 15
Source File: RedisConfig.java    From fw-spring-cloud with Apache License 2.0 4 votes vote down vote up
@Bean
public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
	return redisTemplate.opsForValue();
}
 
Example 16
Source File: RedisTemplateConfiguration.java    From mica with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ValueOperations.class)
public ValueOperations valueOperations(RedisTemplate redisTemplate) {
	return redisTemplate.opsForValue();
}
 
Example 17
Source File: RedisConfig.java    From sophia_scaffolding with Apache License 2.0 2 votes vote down vote up
/**
 * 实例化 ValueOperations 对象,可以使用 String 操作
 *
 * @param redisTemplate
 * @return
 */
@Bean
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
    return redisTemplate.opsForValue();
}
 
Example 18
Source File: RedisConfig.java    From sophia_scaffolding with Apache License 2.0 2 votes vote down vote up
/**
 * 实例化 ValueOperations 对象,可以使用 String 操作
 *
 * @param redisTemplate
 * @return
 */
@Bean
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
    return redisTemplate.opsForValue();
}