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

@Cached @CacheRefresh 和 cacheManager 对同一缓存设置,@Cached @CacheRefresh作用失效。 #959

Open
sonny-qi opened this issue Jan 24, 2025 · 1 comment

Comments

@sonny-qi
Copy link

@PostConstruct
public void init() {
QuickConfig idQc = QuickConfig.newBuilder(":user:cache:id:")
.cacheType(CacheType.BOTH)
.expire(Duration.ofSeconds(60))
.syncLocal(true)
.build();
idUserCache = cacheManager.getOrCreateCache(idQc);
}

@cached(name = ":user:cache:id:", key = "#userId", expire = 100)
@cacherefresh(refresh = 30)
public User findById(Long userId) {
System.out.println("调用几次这个");
return userMapper.findById(userId);
}
cacheManager 是不是对全局有效,会覆盖后面 @cached @cacherefresh的策略

@areyouok
Copy link
Collaborator

area和name相同的就是同一个,只能定义一次

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

2 participants