public static void updateRates(String type, long rate) { LOGGER.debug("updateRates : type={}, rate={}", type, rate); Iterator<RateLimiterDescriptor> iterator = rateLimiterMap.asMap().keySet().iterator(); while (iterator.hasNext()) { RateLimiterDescriptor oldRateDesc = iterator.next(); if (type.equals(oldRateDesc.getType())) { LOGGER.trace("updateRates : invalidated rate={}", oldRateDesc); rateLimiterMap.invalidate(oldRateDesc); RateLimiterDescriptor newRateDesc = new RateLimiterDescriptor(oldRateDesc.getType(), oldRateDesc.getAppId(), rate); LOGGER.trace("updateRates : updating rate desc={}, rate={}", newRateDesc, rate); rateLimiterMap.put(newRateDesc, RateLimiter.create(rate)); rateLimiterMap.refresh(newRateDesc); } } }
@Override public void refresh(final K key) { final LoadingCache<K, V> cache = getCacheNonNull(key); cache.refresh(key); }