title: How to thread-safe update loadingcache value guava map
body: <p>For the test, in the addCache method, I created and added a map. The card has a key &quot;a&quot; and a value &quot;1111&quot;. And key &quot;b&quot; for LoadingCache.</p>
  <p>Next, I want to update the value &quot;1111&quot; to the value &quot;2222&quot;. To do this, I pass all the necessary parameters from the main method to find the value &quot;1111&quot;.</p>
  <p>How can I update &quot;1111&quot; to &quot;2222&quot; in a thread-safe way?</p>
  <pre><code>    public class TestCache {
  
  
          private LoadingCache&lt;String, Map&lt;String, String&gt;&gt; attemptsCache;
  
          public TestCache() {
  
              attemptsCache = CacheBuilder.newBuilder()
                      .maximumSize(10000)
                      .expireAfterWrite(1, TimeUnit.HOURS)
                      .build(new CacheLoader&lt;String, Map&lt;String, String&gt;&gt;() {
                          @Override
                          public Map&lt;String, String&gt; load(@Nonnull final String key) {
                              return Map.of();
                          }
                      });
          }
  
  
          public void addCache(final String pathKey, final String inputKey, final String nameValue) {
  
              Map&lt;String, String&gt; map = new HashMap&lt;&gt;();
              map.put(&quot;a&quot;, &quot;1111&quot;);
              attemptsCache.put(&quot;b&quot;, map);
  
              // Next, you need to update the map value
  
          }
  
          
          public static void main(String[] args) throws ExecutionException {
  
              new TestCache().addCache(&quot;b&quot;,&quot;a&quot;,&quot;2222&quot;);
  
          }
  
  
  
      }
  </code></pre>