import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import java.util.concurrent.TimeUnit; public class Main { public static void main(String[] args) { Cache<String, String> cache = CacheBuilder.newBuilder() .build(); cache.put("key1", "value1"); cache.put("key2", "value2"); String value1 = cache.getIfPresent("key1"); System.out.println("Value 1: " + value1); String value3 = cache.getIfPresent("key3"); System.out.println("Value 3: " + value3); } }


上一篇:
下一篇:
切换中文