Code example for Cache

Methods: asMapsize

0
		Cache<String, Boolean> cache = CacheBuilder.newBuilder()
				.expireAfterAccess(10, TimeUnit.MILLISECONDS)
				.build();
 
		// create evicting Set out of the Cache data structures 
		Set<String> set = Sets.newSetFromMap(cache.asMap());
 
		// there are no entries initially 
		assertEquals(0, set.size());
 
		// add an entry directly in the Set (do not use Cache APIs) 
		set.add("value");
 
		// make sure the cache sees the new entry 
		assertEquals(1, cache.size());
 
		// sleep a while to expire the entry 
		Duration.milliseconds(50).sleep(); 
 
		// the entry should be considered expired now 
Connect your IDE to all the code out there  Get Codota for Java