Skip to content

Commit

Permalink
Make NetworkLocationCache load asynchronously
Browse files Browse the repository at this point in the history
NetworkLocationCache loads synchronously because refresh() calls load()
directly, if the value is missing from the cache. This change sets the
cache entry to the "root" location, and then refreshes it asynchronously
to retrieve the correct value
  • Loading branch information
cberner committed Jan 20, 2016
1 parent 6ad5d72 commit f48edc4
Showing 1 changed file with 2 additions and 0 deletions.
Expand Up @@ -75,6 +75,8 @@ public Optional<NetworkLocation> get(HostAddress host)
{
NetworkLocation location = cache.getIfPresent(host);
if ((location == null) && (negativeCache.getIfPresent(host) == null)) {
// Store a value in the cache, so that refresh() is done asynchronously
cache.put(host, new NetworkLocation());
cache.refresh(host);
}
return Optional.ofNullable(location);
Expand Down

0 comments on commit f48edc4

Please sign in to comment.