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是否可以一次设置多个key? #868

Open
SunnySideCoder opened this issue Mar 21, 2024 · 2 comments
Open

Cached是否可以一次设置多个key? #868

SunnySideCoder opened this issue Mar 21, 2024 · 2 comments

Comments

@SunnySideCoder
Copy link

Hi,是否可以像springcache那样一次设置多个缓存

@Caching(put = {
        @CachePut(value = CachePoolDefName.adminToken, key = "'userId:' + #userId"),
        @CachePut(value = CachePoolDefName.adminToken, key = "'token:' + #result.token")
})

public Token test(long userId){
return new Token();
}

@areyouok
Copy link
Collaborator

CacheUpdate/CacheInvalidate有个multi属性,可以put/remove多次,不过能干的事情也比较简单。

可以看看源代码里面的注释,文档里面好像没有写。

@SunnySideCoder
Copy link
Author

感谢解惑
已实现,虽然需要再定义一个相同name的 @cached 但能满足我目前的需求
@CacheUpdate(name = CachePoolDefName.adminToken, key = "new String[]{'userId:' + #userId,'token:' + #result.token}", value = "new Object[]{#result,#result}", multi = true)

现在又有新的问题产生了,a项目里面用户登录生成了缓存A1,需要在B项目中封禁该用户并删除缓存A1,删除时会报错Cache operation aborted because can't find cached definition
请问这个是否有解决方案呢

CacheUpdate/CacheInvalidate有个multi属性,可以put/remove多次,不过能干的事情也比较简单。

可以看看源代码里面的注释,文档里面好像没有写。
@areyouok

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