Questions tagged [caffeine]

Caffeine is an open source cache for Java 8 and above. It offers a near optimal hit rate, excellent concurrent performance, and a variety of features packed into a simple API.

Caffeine is a robust, feature packed, high performance cache for the Java ecosystem.

The cache is an evolution of two highly successful, popular libraries. It provides the features and similar interfaces as Google Guava's cache, but modernized for Java 1.8+. Caffeine's and Guava's concurrency model are based on ConcurrentLinkedHashMap, a cache often used by performance critical products like Apache Cassandra. The experiences learned developing those libraries, as well as newly published research, allow Caffeine to continue to push the envelope of what to expect from a modern cache.

Downloads and more information: https://github.com/ben-manes/caffeine

128 questions
0
votes
0 answers

Caffeine cache - maximumSize eviction seems not to be late

We have an issue with Caffeine cache. We configured it to be of size 60, with TTL of 300 seconds like this: Cache cache = Caffeine.newBuilder() .expireAfterWrite(300, TimeUnit.SECONDS) …
Aladin
  • 492
  • 1
  • 8
  • 21
0
votes
2 answers

Trouble configuring spring caffeine cache manager

I have a spring boot project which serves as a library (packaged jar file) to some other project. I am trying yo configure caffeine cache that will refresh asynchronously after request is made to the service. pom.xml (includes) :
Einstein_AB
  • 396
  • 5
  • 22
0
votes
1 answer

Caffeine AsyncLoadingCache and thundering herd

Does .get() on a Caffeine AsyncLoadingCache prevent concurrent loads, by delaying subsequent threads which are calling .get() until the first one completes? Or that it can be configured to return a stale value while a self-populating load request is…
rrva
  • 190
  • 1
  • 8
0
votes
1 answer

Cache Kafka Records using Caffeine Cache Springboot

I am trying to cache Kafka Records within 3 minutes of interval post that it will get expired and removed from the cache. Each incoming records which is fetched using kafka consumer written in springboot needs to be updated in cache first then if it…
0
votes
0 answers

How can I get a return value from a Coroutine Scope in Kotlin?

I'm building a cache using Caffeine and Kotlin. I have something like this: private val esCache: Cache = Caffeine.newBuilder() .expireAfterWrite(30, TimeUnit.SECONDS) .refreshAfterWrite(50, TimeUnit.SECONDS) …
Lais Bento
  • 13
  • 4
0
votes
1 answer

Dynamically toggling recording stats on Caffeine Cache

I would like to be able to dynamically toggle the recording of stats of Caffeine Caches on demand via REST endpoint, or JMX Method We have a large scale application where we use several instances of Caffeine Caches. We could use every possible…
Javo
  • 435
  • 1
  • 5
  • 16
0
votes
1 answer

ConcurrentHashMap compute in guava/caffeine/? cache

Since Java 8 we can use .compute* methods on ConcurrentHashMap to synchronize processing by key, so that if two threads execute .compute* method on the same key at the same time, callbacks still will be executed one after another and not…
Kivan
  • 1,712
  • 1
  • 14
  • 30
0
votes
1 answer

How to test inmemory caching using Caffeine cache manager? (i.e. getting the count of entries in cache after caching, cache evict)

I want to get the details of entries in my custom cache after caching data or eviction of data. I tried using actuator dependency to get 'actuator/metrics' path to get details but I'm getting empty tomcat server cache. There is no sign of my custom…
Devender Kumar
  • 107
  • 1
  • 12
0
votes
1 answer

Missing caffeine dependency for Corda Enterprise 4.0

When attempting to compile my project on Corda Enterprise 4.1 for the first time this stack trace for a missing dependency came up. How can I include the correct Caffeine dependency? Could not resolve all files for configuration…
Austin Moothart
  • 378
  • 2
  • 13
0
votes
1 answer

How to create ExpensiveGraph

I want to use below code in my application LoadingCache graphs = Caffeine.newBuilder() .maximumSize(10_000) .build(key -> createExpensiveGraph(key)); But, I am so dumb in multithreading that I could not figure it out how do I…
user3289405
  • 127
  • 1
  • 9
0
votes
0 answers

Caffeine Cache always return null with getIfPresent method

I am trying to implement Caffeine cache to avoid brute force login attempts. So that I have a cache with key = IP adress and value = number of login attempts. I have a service which builds Caffeine cache and some methods to handle login failed and…
rawsly
  • 372
  • 1
  • 5
  • 20
0
votes
1 answer

Unit tests on Caffeine LoadingCache implementation pass individually but one fails when run together

The unit tests (JUnit, Mockito) that I've written for my Caffeine CacheLoader implementation all succeed when I run them individually, but one of them fails when I run them all together. I believe that I am following best practices in using @Before…
Groppe
  • 3,819
  • 12
  • 44
  • 68
0
votes
1 answer

@Cacheable and initialization during startup

I would like to initialize all entries in cache during startup of my spring boot application (loading stuff from DB). Ideally, this is done before the application is already ready. So I implemented all loading in @PostConstruct. I remarked, that the…
badera
  • 1,495
  • 2
  • 24
  • 49
0
votes
3 answers

Binding @ConfigurationProperties to builder used to create bean

I'm creating multiple Caffeine caches like: @Bean public Cache customerCache() { return Caffeine.newBuilder() .maximumSize(10_000) // other config settings .build(..); } Now I would like to…
Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110
0
votes
1 answer

How to mix SoftWeak save strategy with Timebased?

Good day ! Can I mix Time-based and Reference-based stategy ? I want cache based on SoftReference with 5 minute lifecycles, can I get it from box ?
1 2 3
8
9