Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:39:57+00:00 2026-06-14T06:39:57+00:00

So for example: CacheBuilder.newBuilder() .maximumSize(1000) .expireAfterAccess(1, TimeUnit.MINUTES) .expireAfterWrite(1, TimeUnit.MINUTES) .build(new CacheLoader<String, Object>() { @Override

  • 0

So for example:

CacheBuilder.newBuilder()
            .maximumSize(1000)
            .expireAfterAccess(1, TimeUnit.MINUTES)
            .expireAfterWrite(1, TimeUnit.MINUTES)
            .build(new CacheLoader<String, Object>() {
                @Override
                public Object load (String key) {
                    return ...;
                }
            });

If calling invalidate(key) on the returned instance, a subsequent call to getUnchecked() will ALWAYS use the previous value until at least 1 minute has passed in which cause it will call load(key) again. A call to cleanUp() right after invalidate() seems to have no effect either.

Am I using this feature incorrectly or not understanding something about how the caching is working?

Per http://code.google.com/p/guava-libraries/wiki/CachesExplained:

"At any time, you may explicitly invalidate cache entries rather than waiting for entries to be evicted. This can be done:

individually, using Cache.invalidate(key)"

I would assume that the call to invalidate would take precedence and always make the entry be eligible for eviction (ie, the very next getUnchecked call) even if the time is less than 1 minute.

Edit:: I figured out my issue. The above observation is indeed true and the expected nature of the cache. However, my specific was issue was that I was sometimes calling invalidateAll([]) with an empty List (which doesn’t invalidate anything), when I really needed to call invalidateAll() with no parameters (which invalidates everything). I would almost expect invalideAll([]) to be equivalent to invalidateAll(), but I could see where that would lead to some confusion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:39:59+00:00Added an answer on June 14, 2026 at 6:39 am

    …I’m not clear whether you’re describing your expectations or your observations, but invalidate should remove the entry immediately — not waiting for another query — and should force the value to get reloaded on the very next query to that key. If that’s not what happens, then that’s a bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example: public var myVar:Object; // now I want to get the myVar string //
Example: public class JFrameTest { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() {
Example: error_reporting(E_ALL | E_STRICT); class Test {} $obj = new Test(); $obj->undeclared = oops;
Example: Table: Unit ID NAME VALUE 1 Kilo 1000 2 Mega 1000000 3 Giga
Example model: public class Thing { [JsonProperty(foo)] public string Foo {get;set;} [JsonProperty(bars)] public Dictionary<string,string>
Example code: # -*- coding: utf-8 -*- from functools import wraps class MyClass(object): def
example String : /gasg/string expected result : string Characters to to remove: all characters
Example code: List<Student> Students = new List<Student>() { new Student(101, Hugo, Garcia, new List<int>()
example: NSString *day = [[NSString stringWithFormat:@السبت];and i think the representation of this string in
Example input string: (F1 (F2 X (Y) Z) (F3 A B) What i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.