public MemKeyValueStore() { map = ExpiringMap.builder().expiration(Integer.MAX_VALUE, TimeUnit.DAYS).variableExpiration().build(); try { Field field = map.getClass().getDeclaredField("writeLock"); field.setAccessible(true); writeLock = (Lock) field.get(map); } catch (ReflectiveOperationException | SecurityException e) { throw new RuntimeException(e); } }
public RedisCacheEnabledInterceptor() { this(Executors.newSingleThreadScheduledExecutor(), ExpiringMap.builder().variableExpiration().<String, CachedValueWrapper>build()); }
/** * Sets the ExpiringEntryLoader to use when loading entries and configures {@link #variableExpiration() variable * expiration}. Either an EntryLoader or ExpiringEntryLoader may be set, not both. * * @param loader to set * @throws NullPointerException if {@code loader} is null * @throws IllegalStateException if an {@link #entryLoader(EntryLoader) EntryLoader} is set */ @SuppressWarnings("unchecked") public <K1 extends K, V1 extends V> Builder<K1, V1> expiringEntryLoader( ExpiringEntryLoader<? super K1, ? super V1> loader) { assertNoLoaderSet(); expiringEntryLoader = (ExpiringEntryLoader<K, V>) Assert.notNull(loader, "loader"); variableExpiration(); return (Builder<K1, V1>) this; }
/** * Sets the ExpiringEntryLoader to use when loading entries and configures {@link #variableExpiration() variable * expiration}. Either an EntryLoader or ExpiringEntryLoader may be set, not both. * * @param loader to set * @throws NullPointerException if {@code loader} is null * @throws IllegalStateException if an {@link #entryLoader(EntryLoader) EntryLoader} is set */ @SuppressWarnings("unchecked") public <K1 extends K, V1 extends V> Builder<K1, V1> expiringEntryLoader( ExpiringEntryLoader<? super K1, ? super V1> loader) { assertNoLoaderSet(); expiringEntryLoader = (ExpiringEntryLoader<K, V>) Assert.notNull(loader, "loader"); variableExpiration(); return (Builder<K1, V1>) this; }
/** * Sets the ExpiringEntryLoader to use when loading entries and configures {@link #variableExpiration() variable * expiration}. Either an EntryLoader or ExpiringEntryLoader may be set, not both. * * @param loader to set * @throws NullPointerException if {@code loader} is null * @throws IllegalStateException if an {@link #entryLoader(EntryLoader) EntryLoader} is set */ @SuppressWarnings("unchecked") public <K1 extends K, V1 extends V> Builder<K1, V1> expiringEntryLoader( ExpiringEntryLoader<? super K1, ? super V1> loader) { assertNoLoaderSet(); expiringEntryLoader = (ExpiringEntryLoader<K, V>) Assert.notNull(loader, "loader"); variableExpiration(); return (Builder<K1, V1>) this; }
public InMemorySlidingWindowRequestRateLimiter(Set<RequestLimitRule> rules, TimeSupplier timeSupplier) { this(ExpiringMap.builder().variableExpiration().build(), rules, timeSupplier); }