[英]Is there a way to put up different expiry times for different elements I insert in ignitecache?
Can I insert elements having different expiry times like we have in ehcache我可以像在 ehcache 中那样插入具有不同到期时间的元素吗
For example:例如:
Cache: add element1 //expire after 5 seconds缓存:添加元素1 //5秒后过期
cache: add element2 //expire after 15 seconds cache: add element2 //15秒后过期
cache: add element3 //expire after 'x' seconds/minutes缓存:添加元素3 //在'x'秒/分钟后过期
If not, can you suggest any alternative cache to deal with the problem?如果没有,您能否建议任何替代缓存来处理该问题?
I intended to use ehcache as well but turns out it doesn't support active/eager expiry.我也打算使用ehcache,但事实证明它不支持主动/急切到期。
Cache entries have individual expiry policies, use IgniteCache.withExpiryPolicy
:缓存条目有单独的过期策略,使用IgniteCache.withExpiryPolicy
:
cache.withExpiryPolicy(new CreatedExpiryPolicy(new Duration(SECONDS, 5))).put(1, 1);
cache.withExpiryPolicy(new CreatedExpiryPolicy(new Duration(SECONDS, 15))).put(2, 2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.