jedis icon indicating copy to clipboard operation
jedis copied to clipboard

Support for Local Cache Eviction Policy

Open atharva29 opened this issue 1 year ago • 1 comments

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:

atharva29 avatar Oct 01 '24 03:10 atharva29

@atharva29 Thank you for sharing this feature request.

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

sazzad16 avatar Oct 01 '24 05:10 sazzad16

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

atakavci avatar Feb 28 '25 08:02 atakavci

This issue is marked stale. It will be closed in 30 days if it is not updated.

github-actions[bot] avatar Mar 31 '25 00:03 github-actions[bot]