Questions tagged [google-guava-cache]

97 questions
1
vote
1 answer

Scala Guava type mismatch issue

I am trying to implement a simple usecase using Guava caching but facing some issues as shown below: case class Person(x:Int, y:String) val db = Map(1 -> Person(1,"A"), 2 -> Person(2,"B"), 3 -> Person(3,"C")) val loader:CacheLoader[Int,Person] =…
1
vote
0 answers

Openshift - cache management with multiple pods

In one of our project, we are using openshift v3.X to host our spring boot rest services. In the services, we have implemented Guava Cache and we do clear the cache in certain actions. eg. When user wants the list employees from a table, it returns…
user3913069
  • 31
  • 1
  • 3
1
vote
3 answers

How to configure guava cache to remove item after a read?

I would like to remove (invalidate) an item after it was read from a cache. So item should be present in a cache until a first read. I've tried adding expireAfterAccess(0, TimeUnit.NANOSECONDS) but then cache is not populated. Is there any way to…
pixel
  • 24,905
  • 36
  • 149
  • 251
1
vote
2 answers

How to skip / avoid some specific elements to be cached by Guava Cache

Is there a way to not cache some specific elements using Guava Cache? I still want the element to be returned, but not cached. For example: LoadingCache guavaCache; public Element load(String key) { Element element = requestElement(key); …
Marcelo Xavier
  • 322
  • 2
  • 11
1
vote
1 answer

What happend if guava cache is full and no evictable element?

I am using google guava cache with reference-based eviction. I wonder what happened if the cache is full and no element of it is marked as evictable? Is there an out of memory exception thrown?
1
vote
1 answer

How to use Guava Cache with expiry time for an ArrayList?

I just found out about Guava Caching, and all the examples that I see are using map, key, and value. Is there any way to use guava cache for an ArrayList? I have an ArrayList that has elements, each element has 60 seconds to live, after that it…
secret
  • 746
  • 2
  • 14
  • 28
1
vote
1 answer

Guava Cache: Put operation triggers removal listener

I have a cache and am putting new elements into it. Every time I put an item in the cache the removal listener gets triggered. How do I get the removal listener to be triggered only when things are actually being removed or evicted? Cache
newToScala
  • 397
  • 4
  • 16
1
vote
1 answer

Limit cache by deep (opposite to shallow) size of objects in Java?

I am doing cache of images for faster downloading from network share and/or internet. Currently, this cache is in memory. Is it possible to limit cache by deep size of objects (prelimilarly of BufferedImageSize)? Cache is initialized like…
Dims
  • 47,675
  • 117
  • 331
  • 600
1
vote
1 answer

Is removalListener of guava cache runs in a separate thread?

I want to perform some cleaning when the object is removed from guava cache. But I need to do it after some time. Can I put sleep there? Will it block all threads? Or removalListener runs in a separate…
Michael
  • 10,063
  • 18
  • 65
  • 104
1
vote
1 answer

How to understand guava cache stats metrics?

I am using Guava cache in one of my library and that library is being used by some other service (managed by other team) in my company. From my library I am logging cache stats every 50000 times. Below is the the output I see whenever it is getting…
user5447339
1
vote
1 answer

Guava Cache expireAfterWrite is only applicable with getIfPresent used?

This question is to validate an observed behavior to ensure Guava Cache is used in correct way. I have setup two Guava Caches (see code below): with and without a builder - as Guava documentation states: Caches built with CacheBuilder do not…
G T
  • 37
  • 4
1
vote
2 answers

Maven Guava Dependency "Cannot resolve symbol 'google'" in IntelliJ IDEA

IntelliJ says Cannot resolve symbol 'google'. about this import: import com.google.common.cache.LoadingCache; Even though I have added the dependency correctly and it doesn't complain about it: com.google.guava
Atte Juvonen
  • 4,922
  • 7
  • 46
  • 89
1
vote
1 answer

how to deal with dirty data in Guava Cache

I use Guava Cache to cache my data. The data in the cache will be cleaned if it has not been used for several minutes. If I modify my data, I will update the data in cache, and mark the data "dirty"(because it is be modified ,and is different with…
Defit
  • 113
  • 9
1
vote
0 answers

How to Implement a Cache with Time Eviction and Fallback Using Google Guava LoadingCache

Google Guava's Cache is awesome after I read https://github.com/google/guava/wiki/CachesExplained LoadingCache graphs = CacheBuilder.newBuilder() .maximumSize(1000) .expireAfterWrite(10, TimeUnit.MINUTES) …
Peter Lee
  • 12,931
  • 11
  • 73
  • 100
1
vote
1 answer

expiration in com.google.common.collect.MapMaker

I've just download the last release guava com.google.guava guava 20.0-hal and I…
Amadeu Cabanilles
  • 913
  • 3
  • 19
  • 47