@Test(expectedExceptions = IllegalStateException.class) public void ticker_twice() { Caffeine.newBuilder().ticker(Ticker.systemTicker()).ticker(Ticker.systemTicker()); }
private Cache<String, Task> getAddressableCache(final Cache<Addressable, Cache<String, Task>> methodCache, final Addressable addressable) { return methodCache.get(addressable, key -> { Caffeine<Object, Object> builder = Caffeine.newBuilder(); if (cacheExecutor != null) { builder.executor(cacheExecutor); } return builder .ticker(clock == null ? Ticker.systemTicker() : () -> TimeUnit.MILLISECONDS.toNanos(clock.millis())) .build(); }); }
@NonNull Ticker getTicker() { boolean useTicker = expiresVariable() || expiresAfterAccess() || expiresAfterWrite() || refreshes() || isRecordingStats(); return useTicker ? (ticker == null) ? Ticker.systemTicker() : ticker : Ticker.disabledTicker(); }
public void testTicker_setTwice() { Ticker testTicker = Ticker.systemTicker(); Caffeine<Object, Object> builder = Caffeine.newBuilder().ticker(testTicker); try { // even to the same instance is not allowed builder.ticker(testTicker); fail(); } catch (IllegalStateException expected) {} }
/** * Retrieves the cache for a CacheResponse-annotated method. * One is created if necessary. */ private Cache<Addressable, Cache<String, Task>> getMethodCache(Method method) { final CacheResponse cacheResponse = cacheResponseCache.getAnnotation(method); if (cacheResponse == null) { throw new IllegalArgumentException("Passed non-CacheResponse method."); } // if cached, return; otherwise create, cache and return return masterCache.get(method, key -> { Caffeine<Object, Object> builder = Caffeine.newBuilder(); if (cacheExecutor != null) { builder.executor(cacheExecutor); } return builder .ticker(clock == null ? Ticker.systemTicker() : () -> TimeUnit.MILLISECONDS.toNanos(clock.millis())) .maximumSize(cacheResponse.maxEntries()) .expireAfterWrite(cacheResponse.ttlDuration(), cacheResponse.ttlUnit()) .build(); }); }
/** * Create a new message distributor. * * @param periodDurationMillis The period duration in milliseconds. * @param profileTimeToLiveMillis The time-to-live of a profile in milliseconds. * @param maxNumberOfRoutes The max number of unique routes to maintain. After this is exceeded, lesser * used routes will be evicted from the internal cache. */ public DefaultMessageDistributor( long periodDurationMillis, long profileTimeToLiveMillis, long maxNumberOfRoutes) { this(periodDurationMillis, profileTimeToLiveMillis, maxNumberOfRoutes, Ticker.systemTicker()); }
public static <T> CachingPartitionAllocator<T> createDefault(int numModuli) { // TODO (jkong): This should ideally be configurable. DistributingModulusGenerator modulusGenerator = new DistributingModulusGenerator(numModuli); return new CachingPartitionAllocator<>( modulusGenerator, ForkJoinPool.commonPool(), Ticker.systemTicker(), Duration.of(5, ChronoUnit.MINUTES)); }
@Nonnull Ticker getTicker() { boolean useTicker = expiresVariable() || expiresAfterAccess() || expiresAfterWrite() || refreshes() || isRecordingStats(); return useTicker ? (ticker == null) ? Ticker.systemTicker() : ticker : Ticker.disabledTicker(); }
@Bean public Ticker ticker() { return Ticker.systemTicker(); }
private static CacheManager createCacheManager( Config config ) { long ttl = config.get( SecuritySettings.auth_cache_ttl ).toMillis(); boolean useTTL = config.get( SecuritySettings.auth_cache_use_ttl ); int maxCapacity = config.get( SecuritySettings.auth_cache_max_capacity ); return new ShiroCaffeineCache.Manager( Ticker.systemTicker(), ttl, maxCapacity, useTTL ); }
public static <T> CachingPartitionAllocator<T> createDefault(int numModuli) { // TODO (jkong): This should ideally be configurable. DistributingModulusGenerator modulusGenerator = new DistributingModulusGenerator(numModuli); return new CachingPartitionAllocator<>( modulusGenerator, ForkJoinPool.commonPool(), Ticker.systemTicker(), Duration.of(5, ChronoUnit.MINUTES)); }
.ticker(ticker == null ? Ticker.systemTicker() : ticker) .writer(new CacheWriter<HistogramKey, AgentDigest>() { @Override
.ticker(ticker == null ? Ticker.systemTicker() : ticker) .writer(new CacheWriter<HistogramKey, AgentDigest>() { @Override