-
Notifications
You must be signed in to change notification settings - Fork 1.2k
@CacheEvict will remove all keys of current database #2028
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
Comments
That isn't something we can reproduce. We observe proper cache prefixing:
If you would like us to spend additional time helping you to diagnose the problem, please provide a minimal sample that reproduces the problem. |
Yes.
and below is our CacheManager:
As we learned at spring-data-redis 1.X, if set prefix=false, @CacheEvict will run some redis commands like below:
It will only remove keys from the given cache. Anyway spring-date-redis shouldn't remove all keys from current database. |
We generally revised the Redis Cache implementation with the 2.0 upgrade. The cache needs to identify the keys that belong to it and with the change the keyspace provides now the information on which keys belong to the cache, specifically when using the prefix. Please enable key prefixes to address your issue. |
Recently we upgraded spring-data-redis from 1.X to 2.2.6, and found that @CacheEvict didn't work as we understood in 1.X. Below is our sample code.
and a simple testcase:
We monitor the redis commands when running the test cases, the redis commands are as below:
What surprised us was that deleteByPrimaryKey will remove all keys in database #2, in our understanding it should only remove all keys in cache PORTAL_OPERATION_SERVER:CONTENT_CHANNEL_TAG.
We found this commit a9c2b1c#diff-3e7270895c24c01ca01a37cc00a9a27cb48e03d2b2d969a764d31b5e29345ea8 which introduced a huge change to RedisCache, seem it doesn't care the Cache any more.
Please let us know whether we got a misunderstanding.
The text was updated successfully, but these errors were encountered: