import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
public class CacheExample {
public static void main(String[] args) {
Cache<String, String> cache = CacheBuilder.newBuilder()
.maximumSize(100)
.expireAfterWrite(10, TimeUnit.MINUTES)
.build();
cache.put("key1", "value1");
cache.put("key2", "value2");
String value1 = cache.getIfPresent("key1");
System.out.println(value1);
String value3 = cache.getIfPresent("key3");
}
}