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

Support for Local Cache Eviction Policy #3983

Open
atharva29 opened this issue Oct 1, 2024 · 2 comments
Open

Support for Local Cache Eviction Policy #3983

atharva29 opened this issue Oct 1, 2024 · 2 comments

Comments

@atharva29
Copy link

atharva29 commented Oct 1, 2024

Expected behavior

Please add support of TTL, Max Idle , Eviction Policy support to redis server assisted client side caching.
This will reduce the memory requirement on Application's side.

https://github.com/redisson/redisson-examples/blob/master/collections-examples/src/main/java/org/redisson/example/collections/LocalCachedMapExamples.java#L46

        .maxIdle(Duration.ofSeconds(60))
        .timeToLive(Duration.ofSeconds(60))
        .evictionPolicy(EvictionPolicy.LFU)
        .syncStrategy(SyncStrategy.UPDATE)

Write here what you're expecting ...

Actual behavior

Write here what happens instead ...

Steps to reproduce:

Please create a reproducible case of your problem. Make sure
that case repeats consistently and it's not random
1.
2.
3.

Redis / Jedis Configuration

Jedis version:

version as per current date: 5.2.0 GA

Redis version:

Java version:

@sazzad16
Copy link
Contributor

sazzad16 commented Oct 1, 2024

@atharva29 Thank you for sharing this feature request.

Could you please edit your post and add the Jedis version for future reference? Thanks again.

@atakavci
Copy link
Contributor

atakavci commented Feb 28, 2025

hi @atharva29 ,
We will evaluate your request and try to see how we can improve CSC with considerations on memory.
Having said that, with the latest enhancements in CSC, we now support custom EvictionPolicy implementations, along with additional options that provide more control for consumer applications. For memory management, you can configure the maxSize and cacheable properties to see how they can benefit your use case.

Here’s an example of how you can set it up:

    AllowAndDenyListWithStringKeys cacheable = 
        new AllowAndDenyListWithStringKeys(null, null, Collections.singleton("foo"), null);
    EvictionPolicy myPolicy = new MyCustomEvictionPolicy();
    CacheConfig.builder().evictionPolicy(myPolicy).maxSize(1000).cacheable(cacheable).build();

For further details and an example demonstration, check out the following link: 👇
https://github.com/Redislabs-Solution-Architects/redis-client-side-caching-csc-jedis-demo?tab=readme-ov-file#custom-cacheable-logic

let us know if it works for you..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants