热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_42992743
子恒赵
6 年前
trueweixin_42992743

时基法编程之按键

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
guava缓存创建分为两种,一种是CacheLoader,另一种则是callback方式CacheLoader:LoadingCache<String,String> cahceBuilder=CacheBuilder .newBuilder() .build(new CacheLoader<String, String>(){ @Override public String load(String key) throws Exception { String strProValue="hello "+key+"!"; return strProValue; } }); System.out.println(cahceBuilder.apply("begincode")); System.out.println(cahceBuilder.get("begincode")); api中推荐使用get方法获取值callback方式: Cache<String, String> cache = CacheBuilder.newBuilder().maximumSize(1000).build(); String resultVal = cache.get("code", new Callable<String>() { public String call() { String strProValue="begin "+"code"+"!"; return strProValue; } }); System.out.println("value : " + resultVal);
立即登录