title: Does iterating over a Guava LoadingCache's map-view entry set reset the access time used for expiration?
body: <p>I have a <a href="https://google.github.io/guava/releases/23.0/api/docs/com/google/common/cache/LoadingCache.html" rel="nofollow noreferrer"><code>LoadingCache&lt;K,V&gt;</code></a> created using a <a href="https://google.github.io/guava/releases/23.0/api/docs/com/google/common/cache/CacheBuilder.html" rel="nofollow noreferrer"><code>CacheBuilder</code></a>:</p>
  
  <pre><code>LoadingCache&lt;K,V&gt; myCache = CacheBuilder.newBuilder()
      .expireAfterAccess(1, TimeUnit.MINUTES)
      .maximumSize(500)
      .build(someCacheLoader);
  </code></pre>
  
  <p>I need to periodically iterate over all of the entries (keys and values) in the cache. I know I can accomplish that using <a href="https://google.github.io/guava/releases/23.0/api/docs/com/google/common/cache/LoadingCache.html#asMap--" rel="nofollow noreferrer"><code>LoadingCache#asMap()</code></a>, and either:</p>
  
  <ul>
  <li>iterate over that map view's <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Map.html#entrySet%28%29" rel="nofollow noreferrer"><code>Map#entrySet()</code></a>, or</li>
  <li>iterate over just the <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Map.html#keySet%28%29" rel="nofollow noreferrer"><code>Map#keySet()</code></a>, and explicitly <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Map.html#get%28java.lang.Object%29" rel="nofollow noreferrer"><code>Map#get(Object)</code></a> the values.</li>
  </ul>
  
  <p>In the former case:</p>
  
  <pre><code>for (Map.Entry&lt;K, V&gt; entry : myCache.asMap().entrySet()) {
      K key = entry.getKey();
      V value = entry.getValue();
  
      doSomeWorkOn(key, value);
  }
  </code></pre>
  
  <p>Will this update the access time of every entry in the cache? I've read the JavaDoc for <a href="https://google.github.io/guava/releases/23.0/api/docs/com/google/common/cache/CacheBuilder.html#expireAfterAccess-long-java.util.concurrent.TimeUnit-" rel="nofollow noreferrer"><code>CacheBuilder#expireAfterAccess(long, TimeUnit)</code></a> pretty closely, but have found it to be ambiguous/unclear in this case:</p>
  
  <blockquote>
    <p>Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last access. Access time is reset by all cache read and write operations (including <code>Cache.asMap().get(Object)</code> and <code>Cache.asMap().put(K, V)</code>), but not by operations on the collection-views of <code>Cache.asMap</code>.</p>
  </blockquote>
  
  <p>Clearly, the second way of iterating that I mentioned <em>does</em> reset the access time, but I'd like to know what the behavior is using the first way.</p>