| | |
| | | |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | import redis.clients.jedis.Jedis; |
| | | import redis.clients.jedis.JedisPool; |
| | | import redis.clients.jedis.Pipeline; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | private Timer timer; |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | /** |
| | | * 向redis中存储字符串没有过期时间 |
| | |
| | | * @param value |
| | | * @param time 秒 |
| | | */ |
| | | public void setStrValue(String key, String value, int time){ |
| | | if(ToolUtil.isNotEmpty(key) && ToolUtil.isNotEmpty(value)){ |
| | | Jedis resource = jedisPool.getResource(); |
| | | String setex = resource.setex(key, time, value); |
| | | closeJedis(resource); |
| | | } |
| | | public void setStrValue(String key, String value, long time){ |
| | | redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | |