question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local cache not working as expected when executing get, put and get operations on the same key

See original GitHub issue

This 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:

  1. get initial value
  2. put new value
  3. 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mrnikocommented, Nov 25, 2021

Fixed! Thanks for report

1reaction
mrnikocommented, Nov 25, 2021

@ipalbeniz I’ll release it during next week.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found