Local cache not working as expected when executing get, put and get operations on the same key
See original GitHub issueThis is a extension of the issue #3966 because we could not reproduce the problem with the provided test. So, we are trying to provide a new test trying to reproduce the actual issue that we observed on our application.
Expected behavior
We execute these operations on a local cache that points to a redis map already initialized:
- get initial value
- put new value
- get new value
We expect to receive the new value on the third operation.
Actual behavior
Sometimes we get the initial value on the third operation.
Steps to reproduce or test case
A test to reproduce the issue:
@Test
public void testLocalCacheGetAndPut() {
int numberOfKeys = 5_000;
initializeRedis(numberOfKeys);
RMap<String, String> localCachedMap = redisson.getLocalCachedMap("test", LocalCachedMapOptions.defaults());
for (int i = 0; i < numberOfKeys; i++) {
localCachedMap.get("key" + i);
localCachedMap.put("key" + i, "value-" + i);
String cachedValue = localCachedMap.get("key" + i);
assertThat(cachedValue).isEqualTo("value-" + i);
}
}
private void initializeRedis(int numberOfKeys) {
RMap<String, String> map = redisson.getMap("test");
for (int i = 0; i < numberOfKeys; i++) {
map.put("key" + i, "initial-value");
}
}
It fails on different iterations when you execute the test more than once:
org.opentest4j.AssertionFailedError:
expected: "value-377"
but was: "initial-value"
(...)
org.opentest4j.AssertionFailedError:
expected: "value-1109"
but was: "initial-value"
(...)
org.opentest4j.AssertionFailedError:
expected: "value-0"
but was: "initial-value"
Redis version
Redis 5.0.7
Redisson version
3.16.5-SNAPSHOT
Redisson configuration
Default configuration
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Fallback cache key only works for distributed cache (#27537)
I've been trying to get the runner to use a default cache if the branch specific one hasn't been made yet. We're using...
Read more >Failed to synchronize cache for repos for RHEL 8
When I run dnf repolist on rhel 8 enabled machine I see the following error "Failed to synchronize cache for repo" as seen...
Read more >Application Data Caching - Quarkus
The problem is that you have to rely on an external meteorological service ... you can add the cache extension to your project...
Read more >Caching Dependencies - CircleCI
Automatic dependency caching is not available in CircleCI, ... steps: - restore_cache: keys: # Find a cache corresponding to this specific package-lock.json ...
Read more >Caching challenges and strategies - Amazon AWS
The problem might be that calls to this other service are slow or that the database is expensive to scale out as call...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Fixed! Thanks for report
@ipalbeniz I’ll release it during next week.