import com.github.benmanes.caffeine.cache.*; public class ExampleClass { private static final LoadingCache<String, String> cache = Caffeine.newBuilder() .maximumSize(1000) .expireAfterWrite(10, TimeUnit.MINUTES) .build(key -> loadFromDatabase(key)); /** */ @Requires("key != null") @Ensures("result != null") public static String getValue(String key) { return cache.get(key); } }


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