Examples of CacheBuilder


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

Examples of com.google.common.cache.CacheBuilder

        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

Examples of com.google.common.cache.CacheBuilder

        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

Examples of com.google.common.cache.CacheBuilder

        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

Examples of com.googlecode.concurrentlinkedhashmap.caches.CacheBuilder

  }

  @Override
  @SuppressWarnings("rawtypes")
  public void init(Map parameters) throws Exception {
    map = new CacheBuilder()
        .concurrencyLevel(concurrencyLevel)
        .initialCapacity(initialCapacity)
        .maximumCapacity(maximumCapacity)
        .makeCache(cache);
  }
View Full Code Here

Examples of com.googlecode.concurrentlinkedhashmap.caches.CacheBuilder

    Set<Policy> seen = EnumSet.noneOf(Policy.class);
    for (Cache cache : Cache.values()) {
      if (!seen.add(cache.policy())) {
        continue;
      }
      Map<String, String> map = new CacheBuilder()
          .maximumCapacity(capacity)
          .makeCache(cache);
      System.out.println(cache.policy().toString() + ":");
      for (List<String> workingSet : workingSets) {
        System.out.println(determineEfficiency(map, workingSet));
View Full Code Here

Examples of com.googlecode.concurrentlinkedhashmap.caches.CacheBuilder

    assertThat(evictionList, is(equalTo(asList(expect))));
  }

  @Test
  public void evict_efficiency() {
    Map<String, String> expected = new CacheBuilder()
        .maximumCapacity(capacity())
        .makeCache(Cache.LinkedHashMap_Lru_Sync);
    Map<String, String> actual = new Builder<String, String>()
        .maximumWeightedCapacity(capacity())
        .build();
View Full Code Here

Examples of com.googlecode.concurrentlinkedhashmap.caches.CacheBuilder

    case 2: return null; // new CliffWrapHerlihy(); // was a non-blocking HashSet implementation from Maurice Herlihy
    case 3: return new ConcurrentHashMap<String,String>(_table_size,0.75f16); // force to   16 striping
    case 4: return new ConcurrentHashMap<String,String>(_table_size,0.75f, 256); // force to  256 striping
    case 5: return new ConcurrentHashMap<String,String>(_table_size,0.75f,4096); // force to 4096 striping
    case 6: return new NonBlockingHashMap<String,String>();
    case 7: return new CacheBuilder().maximumCapacity(Integer.MAX_VALUE).makeCache(Cache.LinkedHashMap_Lru_Sync);
    case 8:
      return new ConcurrentLinkedHashMap.Builder<String, String>()
          .concurrencyLevel(16) // force to 16 striping
          .initialCapacity(_table_size)
          .maximumWeightedCapacity(Integer.MAX_VALUE)
View Full Code Here

Examples of com.googlecode.concurrentlinkedhashmap.caches.CacheBuilder

  private ConcurrentMap<Integer, Integer> map;
  private int index;

  @Override
  protected void setUp() {
    map = new CacheBuilder()
        .maximumCapacity(Integer.MAX_VALUE)
        .makeCache(cache);
    for (int i = 0; i < ints.size(); i++) {
      map.put(ints.get(i), DUMMY);
    }
View Full Code Here

Examples of com.volantis.cache.CacheBuilder

                enabled = false;
                maxEntries = 0;
            }
        }
        if (enabled) {
            final CacheBuilder cacheBuilder =
                CacheFactory.getDefaultInstance().createCacheBuilder();
            cacheBuilder.setMaxCount(maxEntries);
            final SystemClock clock = SystemClock.getDefaultInstance();
            cacheBuilder.setClock(clock);
            cacheBuilder.setExpirationChecker(
                new URLContentValidationChecker());
            cache = cacheBuilder.buildCache();
        } else {
            cache = null;
        }
        cacheInitialized = true;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.