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
1
vote
0 answers

Caffeine Cache not loading from memory

We are using Caffeine for caching purpose. The setup seems to be pretty simple. We setup the cache in the following way LoadingCache, Result> cache = Caffeine.newBuilder() .maximumSize(1000) …
lakshmi
  • 385
  • 3
  • 8
  • 18
1
vote
1 answer

Caffeine cache key in spring data jpa

I just tried to store the result of items in the cache and all went well except the key. The SimpleKeyGenerator usually save the object or the result based on the arguments and in my case, I want to store an object in the cache and the key should…
user1115139
1
vote
0 answers

prefetch all entries in java caffeine cache

I am trying to build a cache using https://github.com/ben-manes/caffeine, where I need to fetch all entries during boot up time and I do not know all the keys before hand. My CachLoader has something like this and trying to cache all at startup. But…
user3310917
  • 405
  • 5
  • 13
1
vote
1 answer

How to configure write behind with Caffeine cache?

I want to use Caffeine for caching and I need to have a write-behind. I want to limit the amount of times I write to the database. The documentation speaks of write-back cache so it should be possible, but there is no example there on how to…
Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
0
votes
1 answer

How to configure Caffeine Cache with Spring

I have a simple Spring application. I need to implement caching onto a few services that are expensive to call each time. I have a configuration class like this: @Configuration @EnableCaching public class CachingConfig { @Bean (name =…
Einstein_AB
  • 396
  • 5
  • 22
0
votes
1 answer

Size is not unloading from Caffeine caches

Right now i just wondering why, prob need help also. So when i add values to my list it will be added but after 5 min it will remove, that works But if i do list.size() it still says 1 but there is no values inside public class Test extends…
8803286
  • 81
  • 2
  • 10
0
votes
1 answer

Caffeine cache does not prevent from database queries

I've implemented basic set up of Caffeine cache in Spring Boot app. Below you will find configuration and service method annotated with @Cachable. Unfortunately every call for this method generates database query and new input to cache (with same…
Miłosz
  • 17
  • 4
0
votes
1 answer

Caffeine cache - multiple expire configurations

Expiration can be configured in multiple ways: expireAfterWrite expireAfterAccess expireAfter(Expiry) While all 3 methods look helpful, internally they configure different cache variables. My question is: what is the purpose to have dedicated…
ip.java
  • 83
  • 11
0
votes
1 answer

Caffeine cache in Play Framework doesn't return cached responses

I'm using Caffeine cache implementation with my java Play Framework job to cache outgoing http requests, and I see that in spite of the fact that the cache is up and running, my service still hit the external server every time instead of returning…
Battle_Slug
  • 2,055
  • 1
  • 34
  • 60
0
votes
1 answer

Caffeine cache time-based eviction with cache writer

I'm using a Caffeine cache with the following configuration: datesCache = Caffeine.newBuilder() .maximumSize(1000L) .expireAfterWrite(1, TimeUnit.HOURS) .writer(new CacheWriter
KassHino
  • 1
  • 3
0
votes
1 answer

Reactor CacheMono onCacheMissResume called when cache is present

I want to use cachemono and created a test to evaluate. So I created 2 mono and concatenated. What I notice is that oncachemissresume is called for both mono, but on the second mono, cache is not written. Is there anything wrong with my test? I want…
Winster
  • 943
  • 10
  • 28
0
votes
1 answer

Autowire CacheManger (Caffeine & Ehcache) without using @SpringBootApplication

I have a common caching module which has spring boot starter cache (version 2.2.4.RELEASE) and for caching has dependencies of ehcache & caffeine. Below is the pom file
Aky
  • 1
  • 1
  • 2
0
votes
1 answer

Java to Kotlin constructor method

When I move my service's constructor method to Kotlin code, I get a "Method is never used" message. What would be the correct way to transfer the below method to a Kotlin service? I think an init block could be used instead but I'm not sure. public…
C96
  • 477
  • 8
  • 33
0
votes
1 answer

How many Caffeine Cache instances in an application is too much?

I have a use case where I want to Cache a Map of elements against String keys where each element in the map can have its own expiry. I was planning to use a Cache of Caches and utilize the really cool variable expiry in Caffeine. So something…
ab m
  • 422
  • 3
  • 17
0
votes
0 answers

Example of Caffeine per key expiryusage

Are there any examples of how to use per key expiry in Caffeine? I see the following example -- does it mean we are create a Caffeine cache instance per…
ab m
  • 422
  • 3
  • 17
1 2 3
8 9