Questions tagged [google-guava-cache]

97 questions
0
votes
0 answers

Method returning cache results instead of going to the database

I'm running guava cache for my get methods. I've noticed that one of my methods, which retrieves profile information from the database based on name and department, returns ONLY from the cache. If an entry is not in the cache, its supposed to go…
SVill
  • 331
  • 5
  • 22
  • 55
0
votes
0 answers

Guava loading cache, periodically populate cache through db ulk operation

As I have a bulk operation for obtaining data from, so rather than using refresh() to update an individual item, I want to take advantage of bulk call to periodically to update the cache. I have some approaches in mind, as I have get() call to…
0
votes
2 answers

implement a Guava cache to last for ever

I have a cache that holds multiple values (~ 50 records) from a lookup table and I want to put these values in a cache and I don't want it to expire. my implementation look like this : static { cache =…
BaDr Amer
  • 820
  • 11
  • 29
0
votes
1 answer

What's the best way to wait on a scheduled future that has 0 delay?

I am trying to avoid sleeping the current thread until a ScheduledFuture executes with a 0 delay. Unfortunately, I can't find a hook against the future that informs when the runnable executes. The future in question wraps a guava…
Robin Coe
  • 750
  • 7
  • 28
0
votes
1 answer

How to include just caches utility of Guava library in gradle and refuse others?

In Android Studio, I am using CacheBuilder of Guava library: com.google.common.cache.CacheBuilder How to include just this utility?
0
votes
1 answer

Guava cache not taking values from cache and refreshing for every call

I have created cache in my spark application, to refresh few values after every 6 hours. The code looks as below. val cachedList: Cache[String, String] = CacheBuilder.newBuilder() .maximumSize(10) …
Srini
  • 3,334
  • 6
  • 29
  • 64
0
votes
1 answer

Why getAll method of Guava LoadingCache returns different types of ImmutableMap?

I have simple Guava LoadingCache use case where I pass list of key objects to getAll and implemented loadAll to get results when not available in cache. The problem is When cache is empty, Calling getAll for collection of records returns Map of…
Akshay
  • 1,231
  • 1
  • 19
  • 31
0
votes
1 answer

Is it safe to update unrelated values in a Guava cache during a CacheLoader::load call?

I want to store a cache of {organizationId, userId} -> userEmail, but the API available to me returns all emails for a given organization. So long as I'm getting all of these values, is it safe to store them all during a call to…
Andrew Rueckert
  • 4,858
  • 1
  • 33
  • 44
0
votes
1 answer

Cache concurrency RemovalListener

public class testCache { static final Striped lockStriped = Striped.lazyWeakLock(1024); static final Cache cache = CacheBuilder.newBuilder().concurrencyLevel(50).expireAfterAccess(10000l,…
mapek
  • 270
  • 3
  • 16
0
votes
1 answer

Guava : Is Cache.asMap().remove() better?

I want to get & remove an item from Cache final Cache pendingRequest = CacheBuilder.newBuilder().build(); // get first pendingCall = pendingRequest.getIfPresent(key); pendingRequest.invalidate(key); // then remove. I also…
Mr.Wang from Next Door
  • 13,670
  • 12
  • 64
  • 97
0
votes
1 answer

Conditional expireAfterAccess in Google cache

I'm setting up my cache like that: Cache cache = CacheBuilder.newBuilder().expireAfterAccess( 16l, TimeUnit.MINUTES ).build() and class MyClass { String name boolean canExpire } I want the instances with canExpire = true be…
injecteer
  • 20,038
  • 4
  • 45
  • 89
0
votes
1 answer

Guava cache expireAfterAccess issue

I have a question. If I use expireAfterAccess and suppose my entry gets expired after 2 hours. Now if I call get() for that entry after some time (say 5 hours), will it get cached again? or will it expire for good? private final LoadingCache
Boola
  • 358
  • 3
  • 14
0
votes
1 answer

Finding a record in an interval in Guava Cache

I am evaluating some results with Spring SpEL and I would like to cache those results so I don't have to evaluate expressions with same parameters. My cached key object: @Data @AllArgsConstructor public class CachedResult { private String…
alturkovic
  • 990
  • 8
  • 31
0
votes
1 answer

LoadingCache for a list of keys

I have a downstream service which takes the list of ids and return the data for the ids. I am exploring Guava LoadingCache to cache these values. But the loader in the LoadingCache accepts only one key. Are there any ways to use the list of keys.
Navin GV
  • 700
  • 3
  • 10
  • 24
0
votes
1 answer

Guava CacheBuilder evicts items ahead of schedule

I am trying to create a simple cache where I can store some data elements in a map. I need to keep this data around for ~ 16 hours or so, after that I can let the older items expire. I am instantiating my LoadingCache thusly: cache =…
user3892260
  • 965
  • 2
  • 10
  • 19