码迷,mamicode.com
首页 > 编程语言 > 详细

Java缓存类loadingCache

时间:2017-02-23 18:50:09      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:builder   rac   group   ref   utf-8   guava   cache   over   com   

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
LoadingCache<String, String> cache = CacheBuilder.newBuilder()
                    .maximumSize(1000)
                    .expireAfterAccess(3, TimeUnit.SECONDS)
                    .refreshAfterWrite(1, TimeUnit.SECONDS)
                    .build(new CacheLoader<String, String>() {
                        @Override
                        public String load(String s) throws Exception {
                            return s + "cache";
                        }
                    });
            String sss = cache.getUnchecked("sss");

 

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <encoding>UTF-8</encoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

 

Java缓存类loadingCache

标签:builder   rac   group   ref   utf-8   guava   cache   over   com   

原文地址:http://www.cnblogs.com/zhshlimi/p/6434446.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!