Code example for Cache

Methods: getIfPresentinvalidate

0
	}; 
 
	final Cache<String, Download> downloads = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build();
 
	public Download get(String blobId) {
		Download download = downloads.getIfPresent(blobId);
		if (download != null) {
			downloads.invalidate(blobId);
		} 
		return download;
	} 
 
	final SecureRandom r = new SecureRandom();
 
	public String put(Download download) {
		String key;
		synchronized (r) {
			byte[] b = new byte[32];
			r.nextBytes(b);
			key = Hex.encodeHexString(b);
Connect your IDE to all the code out there  Get Codota for Java