Questions tagged [google-guava-cache]

97 questions
13
votes
1 answer

Guava LoadingCache: Why use refreshAfterWrite and expireAfterWrite together

I read this document explaining Guava Cache: CachesExplained. I do understand what refreshAfterWrite and expireAfterWrite are doing. However, while explaining refreshAfterWrite, the document also mentions this: "So, for example, you can specify both…
Z.SP
  • 319
  • 1
  • 2
  • 12
10
votes
2 answers

indirect jar conflict between spring-security-rest and guava causing NoSuchMethod error

I use grails 3.1.16 build.gradle: dependencies { compile "com.google.guava:guava:18.0" compile "org.grails.plugins:spring-security-rest:2.0.0.M2" } while running this code: private LoadingCache attempts …
Tom Boldan
  • 208
  • 1
  • 9
8
votes
1 answer

Guava CacheLoader throw and catch custom exceptions

I am attempting to use the Google Guava Cache to cache by service related objects. On cache miss, I use my REST client to fetch the object. I know that I can do this in the following way: CacheLoader loader = new CacheLoader
RagHaven
  • 4,156
  • 21
  • 72
  • 113
8
votes
3 answers

Unit-testing a class that calls a static method

I am trying to unit-test a class 'A' which calls a static method of a class 'B'. Class 'B' essentially has a google guava cache which retrieves a value(Object) from the cache given a key, or loads the object into the cache (in case of a cache-miss)…
5
votes
1 answer

java - google guava cache difference between invalidateAll() and cleanUp()

Say I have a Cache that is defined like this: private static Cache alertsUIDCache = CacheBuilder.newBuilder(). expireAfterAccess(60).build(); From what I read (please correct me if I am wrong): If value is written to Cache…
Ofek Agmon
  • 5,040
  • 14
  • 57
  • 101
5
votes
1 answer

LoadingCache expireAfterWrite not working as expected

I am having a Loading Cache like this : MyCacheLoader loader=new MyCacheLoader(); MyRemovalListener listener=new MyRemovalListener(); LoadingCache myCache = CacheBuilder.newBuilder() .concurrencyLevel(10) …
HackAround
  • 85
  • 2
  • 9
4
votes
1 answer

Can google cache work in a clustered environment

I am caching data in a singleton ejb using google cache. And the cached resources are used by multiple ejbs. But now am not sure if the same application will work if deployed in a multinoded clustered environment where multiple JVMs can be…
user1455719
  • 1,045
  • 4
  • 15
  • 35
3
votes
1 answer

How to mock Google Guava cache builder?

@Component public class LibraryService { @Autowired private BookService bookService; private Cache bookCache = CacheBuilder.newBuilder().maximumSize(512).expireAfterWrite(15, TimeUnit.MINUTES).build(); …
Damith Ganegoda
  • 4,100
  • 6
  • 37
  • 46
3
votes
1 answer

Concurrent calls to cached method

I'm using Spring cache abstraction with Guava cache. I have a method with @Cacheable annotation and parameter (that serves as a cache key) to put values into the cache. But this method is accessed in a multi threaded env so there are multiple…
mike27
  • 965
  • 3
  • 12
  • 22
3
votes
1 answer

spring - using google guava cache

I'm trying to use google guava cache in my spring app, but result is never caching. This are my steps: in conf file: @EnableCaching @Configuration public class myConfiguration { @Bean(name = "CacheManager") public CacheManager…
griffon vulture
  • 6,594
  • 6
  • 36
  • 57
2
votes
0 answers

Skip elements to be cached by Guava Cache if maximumSize reached

Is there a way to not cache elements using Guava Cache if maximumSize reached? I'm looking for behaviour similar to "No ejection" option in couchbase: If No ejection is selected, no ejection of existing data occurs, and attempts to cache new data…
Stanislav
  • 61
  • 5
2
votes
1 answer

Passing a second argument to Guava Cache load() method

I've previously asked a question on here on how to implement Guava Cache in Java, seen here. While it has worked, I've recently noticed a bug in the getAllProfile method. private LoadingCache> loadingCache =…
SVill
  • 331
  • 5
  • 22
  • 55
2
votes
0 answers

How caching declaration is done for LoadingCache

Can I connect LoadingCache with a @Cacheable method. I need GuavaCache to support refreshAfterWrite return new GuavaCache("cacheName", CacheBuilder.newBuilder() .maximumSize(maxSize) …
2
votes
1 answer

compiler error when using Google guava from scala code

I m using Google Guava from a scala code. And an issue occurs when I m trying to use Int as a key type like in the example: CacheBuilder.newBuilder() .maximumSize(2) .expireAfterWrite(24, TimeUnit.HOURS) .build( new…
Sammers
  • 1,038
  • 2
  • 8
  • 20
2
votes
1 answer

Iterating on values from Guava Cache loses data

I started benchmarking ways to find key by value in Guava cache and I noticed strange behaviour related to concurrency level. I'm not sure if that's a bug or undefined behaviour or maybe even expected but not specified. My benchmark is supposed to…
agilob
  • 6,082
  • 3
  • 33
  • 49
1
2 3 4 5 6 7