Try to search your question here, if you can't find : Ask Any Question Now ?

Designing a Guava LoadingCache with variable entry expiry

HomeCategory: stackoverflowDesigning a Guava LoadingCache with variable entry expiry
Avatarrupesh asked 5 months ago

I am using Guava’s LoadingCache into my project to handle thread-{safe,friendly} cache loading and it works wonderfully well. However, there is a limitation.

The current code defining the cache looks like this:

cache = CacheBuilder.newBuilder().maximumSize(100L).build(new CacheLoader<K, V>()
{
    // load() method implemented here
}

I don’t specify an expiry time.

The problem is that according to the values of the key, some associated values may expire and others may not. And CacheLoader does not account for this, if you specify an expiry time, it is for each and every entry.

How would you tackle this problem?

1 Answers
Best Answer
AvatarFernando answered 5 months ago
Your Answer

12 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com