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

client side cache is not invalidated upon key deletion from the same client #3825

Open
ArielBerkovich opened this issue Apr 27, 2024 · 2 comments

Comments

@ArielBerkovich
Copy link

ArielBerkovich commented Apr 27, 2024

Expected behavior

When a client initiates the deletion of a key, and that key is cached by the client, the cache should be invalidated to prevent retaining invalid data.

Actual behavior

cache is not affected, attempting to get a cached value after its deletion returns it

Steps to reproduce:

run the following unit test:

    @Test
    public void test(){
        JedisClientConfig clientConfig = DefaultJedisClientConfig.builder()
                .resp3()
                .build();
        ClientSideCache clientSideCache =
                GuavaClientSideCache.builder().maximumSize(1000).build();
        UnifiedJedis jedis = new UnifiedJedis(new HostAndPort("127.0.0.1", 6379),
                clientConfig,clientSideCache);

        jedis.set("myKey","myValue");
        jedis.get("myKey"); // cache miss
        jedis.get("myKey"); // cache hit
        jedis.del("myKey");

        Assertions.assertNull(jedis.get("myKey")); 
    }

Jedis version:

5.2.0-beta1

@sazzad16
Copy link
Collaborator

Client side caching does not guarantee immediate update. If you must have the updated data immediately, you should avoid client side caching.

@sazzad16
Copy link
Collaborator

@ArielBerkovich Did you check 5.2.0 GA release?

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