Code example for Cache

Methods: asMapsize

		Cache<String, Boolean> cache = CacheBuilder.newBuilder()
				.expireAfterAccess(10, TimeUnit.MILLISECONDS)
		// 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) 
		// make sure the cache sees the new entry 
		assertEquals(1, cache.size());
		// sleep a while to expire the entry 
		// the entry should be considered expired now 
Experience pair programming with AI  Get Codota for Java