google的cache缓存

       Cache<String,String> cache = CacheBuilder.newBuilder()
                .maximumSize(50000)
                .expireAfterWrite(1, TimeUnit.DAYS)
                .build();
        cache.put("abc", "123456");
        System.out.println("-------" + cache.getIfPresent("abc"));
        cache.put("abc", "1234567890");
        System.out.println("-------" + cache.getIfPresent("abc"));
        cache.invalidateAll();
        System.out.println("-------" + cache.getIfPresent("abc"));

 

posted on 2020-03-04 14:02  zhaoqiang1980  阅读(111)  评论(0编辑  收藏  举报