Package com.google.common.cache

Examples of com.google.common.cache.CacheBuilder


    return !Strings.isNullOrEmpty(cfg.getString("cache", name, var));
  }

  @SuppressWarnings({"rawtypes", "unchecked"})
  private static <K, V> CacheBuilder<K, V> newCacheBuilder() {
    CacheBuilder builder = CacheBuilder.newBuilder();
    return builder;
  }
View Full Code Here


        userCache = getCacheBuilder().build(new UserLoader());
    }


    protected CacheBuilder getCacheBuilder() {
        CacheBuilder builder = CacheBuilder.newBuilder()
                .maximumSize(cacheConfiguration.getSize())
                .refreshAfterWrite(cacheConfiguration.getRefreshMilliSec(), TimeUnit.MILLISECONDS) // reloadable after x time
                .expireAfterWrite(cacheConfiguration.getExpireMilliSec(), TimeUnit.MILLISECONDS) // throw away entries too old
                .recordStats()
                ;
        //.expireAfterAccess(timeoutMillis, TimeUnit.MILLISECONDS)
        //                .removalListener(MY_LISTENER)
        // this should only be used while testing
        if(cacheConfiguration.getCustomTicker() != null) {
            LOGGER.log(Level.SEVERE, "Setting a custom Ticker in the cache {0}", cacheConfiguration.getCustomTicker().getClass().getName());
            builder.ticker(cacheConfiguration.getCustomTicker());
        }
        return builder;
    }
View Full Code Here

        this.maxSize = componentSettings.getAsInt("max_size", 100);
        this.expire = componentSettings.getAsTime("expire", null);
        logger.debug("using [resident] query cache with max_size [{}], expire [{}]", maxSize, expire);

        CacheBuilder cacheBuilder = CacheBuilder.newBuilder().maximumSize(maxSize);
        if (expire != null) {
            cacheBuilder.expireAfterAccess(expire.nanos(), TimeUnit.NANOSECONDS);
        }

        this.cache = cacheBuilder.build();
    }
View Full Code Here

        logger.debug("using script cache with max_size [{}], expire [{}]", cacheMaxSize, cacheExpire);

        this.defaultLang = settings.get(DEFAULT_SCRIPTING_LANGUAGE_SETTING, DEFAULT_LANG);
        this.dynamicScriptingDisabled = DynamicScriptDisabling.parse(settings.get(DISABLE_DYNAMIC_SCRIPTING_SETTING, DISABLE_DYNAMIC_SCRIPTING_DEFAULT));

        CacheBuilder cacheBuilder = CacheBuilder.newBuilder();
        if (cacheMaxSize >= 0) {
            cacheBuilder.maximumSize(cacheMaxSize);
        }
        if (cacheExpire != null) {
            cacheBuilder.expireAfterAccess(cacheExpire.nanos(), TimeUnit.NANOSECONDS);
        }
        cacheBuilder.removalListener(new ScriptCacheRemovalListener());
        this.cache = cacheBuilder.build();

        ImmutableMap.Builder<String, ScriptEngineService> builder = ImmutableMap.builder();
        for (ScriptEngineService scriptEngine : scriptEngines) {
            for (String type : scriptEngine.types()) {
                builder.put(type, scriptEngine);
View Full Code Here

TOP

Related Classes of com.google.common.cache.CacheBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.