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
0
votes
1 answer

How to solve problem with Caffeine storing values

I create cache for manual storing values: private Cache codeCache = Caffeine.newBuilder() .expireAfterWrite(24, TimeUnit.HOURS) .weakKeys() .weakValues() .build(); In public method after some…
Khilarian
  • 249
  • 1
  • 9
0
votes
0 answers

Cannot find cache for Builder when using same Cache Provider in two different dependencies

In my app I have two dependencies, A and B. Dependency A is a library of mine, but dependency B is not. Both dependencies make use of Caffeine to cache the results in memory. This is the configuration for Dependency A…
Marcos
  • 196
  • 1
  • 16
0
votes
0 answers

How to make spring cache return null when value not found in cache but it asynchronously loads the cache for further requests?

I'm using the CaffeineCache implementation and used refreshAfterWrite along with cacheLoader. This will return the stale value if key is present while it loads the new value in cache but what if I want it to return null when key is not present but…
0
votes
1 answer

Caffeine cache metrics only report cache size but not hit/miss ratio with micrometer

I'm using Caffeine cache for Java Spring Boot com.github.ben-manes.caffeine:caffeine:3.1.1. This is my cache configuration class: import com.github.benmanes.caffeine.cache.Caffeine; import org.springframework.cache.CacheManager; import…
hitchhiker
  • 1,099
  • 5
  • 19
  • 44
0
votes
1 answer

How to get all data from Java Spring Cache

i need toknow how to retrieve or where to see al data stored in my cache. @Configuration @EnableCaching public class CachingConf { @Bean public CacheManager cacheManager() { Caffeine cacheBuilder =…
0
votes
2 answers

Problem with @Cachable and @Mock/@InjectMocks

I'm currently unable to use @Cacheble and @Mock/@InjectMocks in the same test class. To be clear, for using the Mockito.verify(repository, times(1)) I need to @Mock the repository and use the annotation @InjectMock for the repository. Doing it, I…
0
votes
0 answers

Caffeine Cache - Updating a collection

I'm working on a Kafka record consumer and comparator. I'm using caffeine to store the consumed messages with a unique I'd for later comparison. Here's a simplified example. // Spring cache configuration Cache> cache =…
rob-DEV
  • 9
  • 4
0
votes
0 answers

Quarkus Caffeine evict cache by pattern

I'm saving the cache for pages like this. Cache depends on username, pageNum, and pageSize. public class UsersLocationsWithUsernameKeyGen implements CacheKeyGenerator { @Override public Object generate(Method method, Object... methodParams) { …
0
votes
0 answers

Moving from caffeine to redisson redis with AWS elatic cache CPU increase

We are moving an in-memory cache implementation of DB results cache to redis(Aws elastic cache). The JVM memory usage for the redisson based redis implementaion in performance test show more CPU usage (about 30 to 50% The blue line is the redisson…
0
votes
0 answers

Springboot - how to store the value of method result into cache

I am trying to store the result returned from a method into Cache ( using Caffeine cache). So in the below method, I want the value of groupId to be put into cache. @Cacheable(value = GROUP_ID_CACHE, key="#result", unless = "#result == null") public…
ljs
  • 495
  • 1
  • 8
  • 23
0
votes
0 answers

How to set maximum memory usage in Caffeine?

I am using Caffeine as cache manager in my project. How can I set maximum memory usage (for example 1GiB)?
Wiktor
  • 71
  • 1
  • 9
0
votes
0 answers

Spring Cacheable - Ignore Feign exceptions, and instead return the last known good result

I have a service, ItemService, that uses a Feign client to get data from an external service. I want to cache the results of the external service and refresh them every X minutes, unless the external service fails, in which case I want to keep using…
aSemy
  • 5,485
  • 2
  • 25
  • 51
0
votes
1 answer

Apache camel filter records based on a list stored in caffeine-cache

I have 2 routes which intends to filter user's messages coming from kafka based on a blacklist of user's ids stored in caffeine cache. The first route that loads a txt file containing ids of blacklisted users at startup, is defined as follow…
Abdelghani Roussi
  • 2,707
  • 2
  • 21
  • 39
0
votes
0 answers

How to call caffeine stats in a seperate class

Is there a way to call caffeine cache in a seperate class implementation. I wrote a Cache configurtion : `@Configuration @EnableCaching(mode = AdviceMode.ASPECTJ) public class CacheConfiguration { @Bean public Caffeine caffeineConfig() { …
Amira
  • 3,184
  • 13
  • 60
  • 95
0
votes
0 answers

Caffeine cache refresh without downtime Spring Boot

Background I am working on a spring boot application. In this application, we have two different caffeine caches - dealDetailsCache and trackingDetailsCache. Both of these caffeine caches have single keys, let us say, X and Y respectively. We just…
1 2 3
8 9