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

fix: expiration time did not respect environment variable #915 #916

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Roiocam
Copy link
Contributor

@Roiocam Roiocam commented Aug 22, 2024

Resolves #915

TODO:

  • verify annotation can be overridden by environment variable
  • verify local expiration time wasn't greater than remote when @Cache(type=BOTH) and not setting localExpire

@Roiocam Roiocam changed the title fix: expiration time did not expect environment #915 fix: expiration time did not respect environment #915 Aug 22, 2024
@Roiocam Roiocam changed the title fix: expiration time did not respect environment #915 fix: expiration time did not respect environment variable #915 Aug 22, 2024
@Roiocam Roiocam marked this pull request as draft August 22, 2024 15:29
@@ -169,15 +165,20 @@ protected CacheResult do_PUT_ALL(Map<? extends K, ? extends V> map, long expireA
return new CacheResult(future);
}

private CacheResult PUT_caches(int lastIndex, K key, V value, long expire, TimeUnit timeUnit) {
private CacheResult PUT_caches(int lastIndex, K key, V value, long expire, TimeUnit timeUnit, boolean isForce) {
CompletableFuture<ResultData> future = CompletableFuture.completedFuture(null);
for (int i = 0; i < lastIndex; i++) {
Cache cache = caches[i];
CacheResult r;
if (timeUnit == null) {
r = cache.PUT(key, value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在这里取min (expire,cache的默认expire)比较好,就不用加isForce参数了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那这样的话,如果用户主动 PUT 一个大于配置时间的过期时间,就不行了。这个 PR 我想到一些边界,还没测试

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你说的这个问题存在,怎么又改回去了呢

@areyouok
Copy link
Collaborator

这个还改吗?

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

Successfully merging this pull request may close these issues.

多级缓存下,仅通过环境变量配置本地过期时间无法生效
2 participants