赞
踩
可以先对key进行赋值,然后对key设置一个过期时间。
(1)依赖
- <dependency>
- <groupId>redis.clients</groupId>
- <artifactId>jedis</artifactId>
- <version>2.7.3</version>
- </dependency>
(2)代码
- public static void hmset(String key, Map<String, String> map, int seconds4ExpireTime) {
- try (Jedis jedis = getJedis()) {
- if (jedis != null) {
- jedis.hmset(key, map);
- jedis.expire(key, seconds4ExpireTime);
- }
- } catch (Exception e) {
- logger.error("RedisUtils.hmset 异常. key:{}, error:", key, e);
- }
- }
(1)https://blog.csdn.net/yilovexing/article/details/128922986
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。