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

  • SEARCH
  • Home
  • 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 8879597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:59:03+00:00 2026-06-14T19:59:03+00:00

My java app has a cache, and I’d like to swap out the current

  • 0

My java app has a cache, and I’d like to swap out the current cache implementation and replace it with the guava cache.

Unfortunately, my app’s cache usage doesn’t seem to match the way that guava’s caches seem to work. All I want is to be able to create an empty cache, read an item from the cache using a “get” method, and store an item in the cache with a “put” method. I do NOT want the “get” call to be trying to add an item to the cache.

It seems that the LoadingCache class has the get and put methods that I need. But I’m having trouble figuring out how to create the cache without providing a “load” function.

My first attempt was this:

LoadingCache<String, String> CACHE = CacheBuilder.newBuilder().build();

But that causes this compiler error: incompatible types; no instance(s) of type variable(s) K1,V1 exist so that Cache conforms to LoadingCache

Apparently I have to pass in a CacheLoader that has a “load” method.

(I guess I could create a CacheLoader that has a “load” method that just throws an Exception, but that seems kind of weird and inefficient. Is that the right thing to do?)

  • 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-14T19:59:04+00:00Added an answer on June 14, 2026 at 7:59 pm

    CacheBuilder.build() returns a non-loading cache. Just what you want. Just use

    Cache<String, String> cache = CacheBuilder.newBuilder().build();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to find out which object in my Java app has a file
I have a Java EE App that has JSF2 + PrettyFaces + Facelets +
I'm planning to implement a process using a java app. The process has various
I am developing an app that has java files and php files. The java
Just wondering if anybody has run Scala app or web-app on Java Real-Time system?
My Java application has got a package structure similar to this: src/com/name/app src/com/name/app/do src/com/name/utils/db
I have a Java app that has an icon in the system tray. How
I have a Java app that has an embedded Derby database (no hibernate though).
I have a standalone Java app that has some licensing code that I want
I am writing a Java App that has multiple items available to test. However

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.