首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用cache2k设置put()的到期时间

如何使用cache2k设置put()的到期时间
EN

Stack Overflow用户
提问于 2017-11-03 11:24:10
回答 1查看 533关注 0票数 1

我想要一些像redis set和ttl这样的东西,例如

公开空放(K键,V值,int timeToLive,TimeUnit timeUnit);

还有一个redis没有提供的手术

公开putWithIdle(K键,V值,int timeToIdle,TimeUnit timeUnit);

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-03 13:24:46

这方面没有直接API,但是在对值进行put处理之后,您可以按照这里描述的更改过期时间( https://cache2k.org/docs/1.0/user-guide.html#entry-processor )

cache.invoke("key", e -> e.setValue("value").setExpiry(System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(120)));

考虑在https://github.com/cache2k/cache2k/issues上创建一个特性请求

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47094626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档