Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

设置key时,ttl会被覆盖修改成-1 #14

Closed
gerryhjs opened this issue Nov 10, 2021 · 4 comments
Closed

设置key时,ttl会被覆盖修改成-1 #14

gerryhjs opened this issue Nov 10, 2021 · 4 comments

Comments

@gerryhjs
Copy link

使用jedis设置key时,如果有ttl可以使用之前的ttl值,防止过期时间被覆盖掉

@MattMin
Copy link
Owner

MattMin commented Nov 11, 2021

Redis就是这样设计的, 可以参考: Redis doc

@gerryhjs
Copy link
Author

@MattMin 我尝试性改了一下可以保留ttl 就不提pr了您看下要是觉得有用可以改一下
case String: try (Jedis jedis = redisPoolManager.getJedis(dbInfo.getIndex())) { try { **jedis.set(key, newValue, new SetParams().ex(Long.parseLong(ttlValue)));** } catch (Exception e) { jedis.set(key, newValue); } } break;

@jumkey
Copy link
Contributor

jumkey commented Nov 11, 2021

你这时间已经不是原来的时间了,与其加个不准的时间 还不如让用户自己设置时间。参考其他客户端也是-1

@gerryhjs
Copy link
Author

好的 那我先close了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants