Questions tagged [caffeine-cache]

A high-performance in-memory cache for Java and other JVM languages.

Caffeine is a cache library with near-optimal performance; flexible configuration; blocking and non-blocking APIs; and integration points for external persistence, monitoring, and plug-in operation with many popular frameworks.

128 questions
2
votes
1 answer

Perform action on expiry with Caffeine on Java

I want to create a cache like so Cache cache = Caffeine.newBuilder() .expireAfterWrite(1, TimeUnit.MINUTES) .maximumSize(100) .build(); That i will populate with a temporary file like…
2
votes
1 answer

Mock Test Cache

I'm trying to test my cache layer with mockito. I'm using Caffeine as described here Basically, I have this... @Service class Catalog { @Autowired Db db; @Cachable public List getItems() { // fetch from db db.someDbMethod(); …
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
2
votes
0 answers

Caffeine Cache with Spring Boot

I have my DAO layers with an expensive method as followed: @Component @CacheConfig(cacheNames = {"userStories"}) public class UserStoryDaoImpl implements IUserStoryDao { @Override @Cacheable public List
Einstein_AB
  • 396
  • 5
  • 22
2
votes
1 answer

Is there a way to enable Caffeine MBean registration?

I am using Scaffeine in my project (https://github.com/blemale/scaffeine), a Scala wrapper for Caffeine (https://github.com/ben-manes/caffeine). I also have a prometheus JMX collector embedded in my metrics API…
Berni
  • 357
  • 3
  • 10
1
vote
1 answer

Refresh Caffeine cache

I want to create a cache instance in in Spring using Caffeine cache. I need the cache to refresh all the keys async, fetching the data from external services and when the data is ready, interchange the old values with the new values without any…
ppk
  • 33
  • 4
1
vote
0 answers

Caffeine 3 - Deprecation of CacheWriter

I have a SpringBoot app with a customized Caffeine cache. Specifically, this cache implements com.github.benmanes.caffeine.cache.CacheWriter to do some post processing after an item is added or removed to the cache. However, the CacheWriter class…
Samantha Catania
  • 5,116
  • 5
  • 39
  • 69
1
vote
0 answers

Using Caffeine Cache, why is the count for cache.puts on manage/metrics endpoint always 0?

I am using Spring Boot 2.7.2 and Caffeine 2.8.5. I have verified the cache is working correctly and all of the other manage/metrics endpoints for cache give the correct counts (cache.eviction.weight, cache.evictions, cache.gets, cache.size), but the…
pesto
  • 11
  • 3
1
vote
1 answer

Is there anyway to refresh the caffeine cache on certain interval wihtout adding TTL?

I have the code like this cache = Caffeine.newBuilder() .build(this::loadData) string loadData(String key) { return redishelpr.get(key); } What I want is run this loadData(key) function after every 15 minutes. I got aapproach of using…
Rupesh
  • 840
  • 1
  • 12
  • 26
1
vote
0 answers

Caffeine Removal Listener functionality does not work on its own

I was trying to use the removalListener functionality of Caffeine Cache, but it does not work as excepted. Below is the code tried: public class CaffeineCacheConfig { @Autowired EmployeeRepository employeeRepository; @Bean public…
Harmandeep Singh Kalsi
  • 3,315
  • 2
  • 14
  • 26
1
vote
0 answers

Caching objects causes frequent Major GC

In my project, I use caffeine cache for caching. The configuration is as follows. cache = Caffeine.newBuilder() .expireAfterWrite(6, TimeUnit.MINUTES) .maximumSize(50_0000.get()) .recordStats() …
Feng Kai
  • 21
  • 3
1
vote
1 answer

FHIR Validation in Android

I have a project in which I have to perform a a FHIR validation. I have implemented this functionality in a regular Java application using the hapi-fhir library with the Instance Validator and Schematron Validator. I am trying to do the same for…
konkouts
  • 51
  • 1
  • 6
1
vote
1 answer

Can you still use a ConcurrentLinkedHashMap with Caffeine?

Caffeine provides a great alternative to Guava's caching library, but can you still use just the ConcurrentLinkedHashMap class itself, or a Cache the implements concurrent, in-order iteration? It does not appear in Caffeine anymore that I can see,…
Ben
  • 4,785
  • 3
  • 27
  • 39
1
vote
1 answer

Spring boot + Caffeine cache + Check header

i'm trying to use cache (caffeine) with Spring boot and im having a problem. I need to check the header "header-name" in every call but application is caching it so after first request with the right header, dont matter what header i send and the…
Marcos Oleiro
  • 27
  • 1
  • 5
1
vote
2 answers

Spring Cache perform action after expires

I'm using Caffeine as Cache Manager integrated with Spring Cache to avoid multiple unnecesary file downloads. Once I download the file, I have its path, which is returned by the download method. I would like to delete the file once the cache…
Leonardo
  • 1,263
  • 7
  • 20
  • 51
1
vote
1 answer

How can I activate JMX for Caffeine cache

I was looking at this SO question, but here I only want Caffeine to start reporting to JMX. I have added an application.conf file as such and referenced it via -Dconfig.file: caffeine.jcache { # A named cache is configured by nesting a new…
Alain P
  • 1,293
  • 8
  • 16
1
2
3
8 9