Skip to content

Instantly share code, notes, and snippets.

@dahernan
Created May 28, 2012 16:43
Show Gist options
  • Save dahernan/2820052 to your computer and use it in GitHub Desktop.
Save dahernan/2820052 to your computer and use it in GitHub Desktop.
Local Cache
// Simple cache
private ConcurrentHashMap<String, String> cache;
String resource = cache.get(url.toString());
...
// Guava
private Cache<String, Boolean> cache;
this.cache = CacheBuilder.newBuilder()
.maximumSize(100)
.concurrencyLevel(50)
.expireAfterWrite(expireTimeInSeconds, TimeUnit.SECONDS)
.build();
cache.getIfPresent(rsc)
cache.put(rsc, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment