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

Using a cache as a layer in front of a database

I'm working on some back-end service which is asynchronous in nature. That is, we have multiple jobs that are ran asynchronously and results are written to some record. This record is basically a class wrapping an HashMap of results (keys are…
IsaacLevon
  • 2,260
  • 4
  • 41
  • 83
1
vote
2 answers

Register Caffeine Cache in Spring Actuator (CacheManager)

We're using Spring Boot 2 and Spring Actuator. When creating a cache like the following: @Bean public CaffeineCache someCache() { return new CaffeineCache("my-cache", Caffeine.newBuilder() .maximumSize(1000) …
AntMor
  • 417
  • 6
  • 18
1
vote
1 answer

spring cloud config refresh cache configuration

Considering the below service how can I dynamically modify the cache configuration with the /actuator/refresh endpoint @Service @Slf4j public class GreetingService { @Cacheable("greeting") public String greet(String name) { …
Zoltan Altfatter
  • 802
  • 2
  • 11
  • 25
1
vote
1 answer

How to add entire table to cache in spring

I have a very small table which is not updated frequently. I want to add this to cache such that it updates every day. I am using spring and caffeine to implement this. I able to load a startup but don't how to refresh it. Please help.…
Mr Nobody
  • 388
  • 4
  • 11
1
vote
0 answers

Examples for testing Caffiene Cache

I'm looking for examples for testing a couple of Caffiene caches I have implemented (one has a timed expiry that is cache-wide and the other has a timed expiry variable per entry using the Expiry interface). Tried to search for good examples online…
RRG
  • 105
  • 9
1
vote
0 answers

Akka actor traversing large sets of data without blocking

I have a akka actor which read from hazelcast and builds a Map[id:String, Set[val:String]]. Now i want to traverse this map and put the following tuple ((id, val))(true) into Scala caffeine cache (another actor). How can i achieve this without…
nocturnal
  • 395
  • 2
  • 6
  • 15
1
vote
1 answer

Caffeine - how expires Cached values only after creation time

Caffeine has expiresAfterWrite method which looks at last write time. I want it to look only at the creation time. So when the first entry comes then entry will be expired after a fixed amount of time without looking at the number of updates on this…
Kapitalny
  • 651
  • 2
  • 8
  • 17
1
vote
1 answer

Eviction Event Listeners for Caffeine or any JVM Cache API?

Java 8 here. Is there any way with the Caffeine caching framework (or any other JSR-107 compatible framework for that matter) to be notified when a record is evicted out of the cache? Maybe some kind of EvictionEventListener or something? public…
hotmeatballsoup
  • 385
  • 6
  • 58
  • 136
1
vote
1 answer

Is it possible to get the set of candidate evicted keys in Caffeine?

I am attempting to use a cache to maintain a list of routable servers based on request type. LoadingCache serversByRequestType = Caffeine.newBuilder() .writer(new CacheWriter() { @Override public…
erip
  • 16,374
  • 11
  • 66
  • 121
1
vote
0 answers

Query regarding saving username and password in application cache

My rest based application is going to receive the encrypted username and password from an upstream application. My application will then interact with a downstream application,the downstream application will implement some logic(takes 1 hour…
Sandy
  • 459
  • 2
  • 6
  • 19
1
vote
1 answer

Spring Boot sync caching with caffeine does not work

I'm using Spring Boot 1.5.12.RELEASE, with caffeine 2.6.2 as caching provider. I have a method in one of my services: @Cacheable(cacheNames = [CacheService.MY_CACHE_NAME], sync = true) fun fetchThing(id: Int, at: OffsetDateTime?): Thing? { …
andrew
  • 3,879
  • 4
  • 25
  • 43
1
vote
0 answers

Evicting In-Memory Cache across multiple instances?

How do we evict in-memory caches at different instances? We have a scale-out architecture, multiple instances service requests simultaneously. Each one of them has in-memory cache attached to it. We need eviction accross all instance, at once. Why…
1
vote
1 answer

Caffeine: Can't provide CacheWriter to AsyncLoadingCache

I'm trying to write a AsyncLoadingCache that accepts a CacheWriter and I'm getting an IllegalStateException. Here's my code: CacheWriter cacheWriter = new CacheWriter() { @Override public void write(String…
svarog
  • 9,477
  • 4
  • 61
  • 77
1
vote
1 answer

How to implement a custom clock in Hazelcast for unit testing?

When testing some of my code with custom expiry durations, I needed to set the clock time in an Hazelcast instance, very much like how I could set the time using a custom Ticker in Caffeine caches. I found that this isn't documented anywhere and…
Isen Ng
  • 1,307
  • 1
  • 11
  • 23
1
vote
1 answer

Spring Boot Multiple Cache Managers in parallel

I have a Spring Boot Web application and using spring session with a redis store. The web requests sometimes need their responses to be cached (to avoid unnecessary db trips) and I planned to use Caffeine. However it seems Redis takes over (as soon…
razvan
  • 559
  • 7
  • 23
1 2 3
8 9