@Test(dataProvider = "caches") @CacheSpec(implementation = Implementation.Caffeine, population = Population.EMPTY, expiry = CacheExpiry.DISABLED) public void expireVariably_notEnabled(Cache<Integer, Integer> cache) { assertThat(cache.policy().expireVariably(), is(Optional.empty())); }
params[i] = expirationPolicy(parameters[i], cache); } else if (clazz.isAssignableFrom(Policy.VarExpiration.class)) { params[i] = cache.policy().expireVariably().get();
@Override public <T> void put(String appid, String id, T object, Long ttlSeconds) { if (ttlSeconds == null || ttlSeconds <= 0L) { put(appid, id, object); return; } if (!StringUtils.isBlank(id) && object != null && !StringUtils.isBlank(appid)) { String key = key(appid, id); cache.policy().expireVariably().ifPresent((t) -> { t.put(key, object, ttlSeconds, TimeUnit.SECONDS); }); logger.debug("Cache.put() {} {} ttl {}", appid, id, ttlSeconds); } }
@Override public <T> void put(String appid, String id, T object, Long ttlSeconds) { if (ttlSeconds == null || ttlSeconds <= 0L) { put(appid, id, object); return; } if (!StringUtils.isBlank(id) && object != null && !StringUtils.isBlank(appid)) { String key = key(appid, id); cache.policy().expireVariably().ifPresent((t) -> { t.put(key, object, ttlSeconds, TimeUnit.SECONDS); }); logger.debug("Cache.put() {} {} ttl {}", appid, id, ttlSeconds); } }