@Test(expectedExceptions = IllegalStateException.class) public void softValues_twice() { Caffeine.newBuilder().softValues().softValues(); }
@Test(expectedExceptions = IllegalStateException.class) public void async_softValues() { Caffeine.newBuilder().softValues().buildAsync(loader); }
@Test public void softValues() { Caffeine.newBuilder().softValues().build(); }
@GwtIncompatible("weakValues") public void testValueStrengthSetTwice() { Caffeine<Object, Object> builder1 = Caffeine.newBuilder().weakValues(); try { builder1.weakValues(); fail(); } catch (IllegalStateException expected) {} try { builder1.softValues(); fail(); } catch (IllegalStateException expected) {} Caffeine<Object, Object> builder2 = Caffeine.newBuilder().softValues(); try { builder2.softValues(); fail(); } catch (IllegalStateException expected) {} try { builder2.weakValues(); fail(); } catch (IllegalStateException expected) {} }
builder.weakValues(); } else if (valueStrength == Strength.SOFT) { builder.softValues(); } else { throw new IllegalStateException();
builder.weakValues(); } else if (valueStrength == Strength.SOFT) { builder.softValues();
builder.softValues();
public void testParse_softValues() { CaffeineSpec spec = parse("softValues"); assertEquals(spec.initialCapacity, UNSET_INT); assertEquals(spec.maximumSize, UNSET_INT); assertEquals(spec.maximumWeight, UNSET_INT); assertNull(spec.keyStrength); assertEquals(Strength.SOFT, spec.valueStrength); assertNull(spec.expireAfterWriteTimeUnit); assertNull(spec.expireAfterAccessTimeUnit); assertNull(spec.refreshAfterWriteTimeUnit); assertCaffeineEquivalence( Caffeine.newBuilder().softValues(), Caffeine.from(spec)); }
public void testParse_whitespaceAllowed() { CaffeineSpec spec = parse(" initialCapacity=10,\nmaximumSize=20,\t\r" + "weakKeys \t ,softValues \n , \r expireAfterWrite \t = 15s\n\n"); assertEquals(10, spec.initialCapacity); assertEquals(20, spec.maximumSize); assertEquals(spec.maximumWeight, UNSET_INT); assertEquals(Strength.WEAK, spec.keyStrength); assertEquals(Strength.SOFT, spec.valueStrength); assertEquals(TimeUnit.SECONDS, spec.expireAfterWriteTimeUnit); assertEquals(15L, spec.expireAfterWriteDuration); assertNull(spec.expireAfterAccessTimeUnit); Caffeine<?, ?> expected = Caffeine.newBuilder() .initialCapacity(10) .maximumSize(20) .weakKeys() .softValues() .expireAfterWrite(15L, TimeUnit.SECONDS); assertCaffeineEquivalence(expected, Caffeine.from(spec)); }
builder.weakValues(); } else if (context.isSoftValues()) { builder.softValues();
builder.weakValues(); } else if (valueStrength == Strength.SOFT) { builder.softValues(); } else { throw new IllegalStateException();
static <Q, T> LoadingCache<Q, T> build(CacheLoader<Q, T> c) { return Caffeine.newBuilder().weakKeys().softValues().build(c); }
static <Q, T> LoadingCache<Q, T> build(CacheLoader<Q, T> c) { return Caffeine.newBuilder().weakKeys().softValues().build(c); }
static <Q, T> LoadingCache<Q, T> build(CacheLoader<Q, T> c) { return Caffeine.newBuilder().weakKeys().softValues().build(c); }
static <Q, T> LoadingCache<Q, T> build(CacheLoader<Q, T> c) { return Caffeine.newBuilder().weakKeys().softValues().build(c); }
/** * Constructs a new {@code BlueprintsPersistenceBackend} wrapping the provided {@code baseGraph}. * <p> * This constructor initialize the caches and create the metaclass index. * <p> * This constructor is protected. To create a new {@code BlueprintsPersistenceBackend} use {@link * BlueprintsPersistenceBackendFactory#createPersistentBackend(java.io.File, Map)}. * * @param baseGraph the base {@link KeyIndexableGraph} used to access the database * * @see BlueprintsPersistenceBackendFactory */ protected BlueprintsPersistenceBackend(KeyIndexableGraph baseGraph) { this.graph = new AutoCleanerIdGraph(baseGraph); this.persistentObjectsCache = Caffeine.newBuilder().softValues().build(); this.verticesCache = Caffeine.newBuilder().softValues().build(); this.indexedEClasses = new ArrayList<>(); Index<Vertex> metaclasses = graph.getIndex(KEY_METACLASSES, Vertex.class); if (isNull(metaclasses)) { metaclassIndex = graph.createIndex(KEY_METACLASSES, Vertex.class); } else { metaclassIndex = metaclasses; } }
CaffeineSharedCache(final int L1Capacity, Cache<CacheKey, byte[]> byteCache, SizeTracker sizeTracker) { this.L2Cache = byteCache; this.sizeTracker = sizeTracker; RemovalListener<CacheKey, RevObject> L1WriteBack = (key, value, cause) -> { if (RemovalCause.SIZE == cause && value != null) { putInternal(key, value); } }; this.L1Cache = Caffeine.newBuilder()// .maximumSize(L1Capacity)// .softValues()// .removalListener(L1WriteBack)// .build(); }
.newBuilder() .maximumSize(ticketCacheSize) .softValues() .expireAfterAccess(ticketCacheExpiration, TimeUnit.MINUTES) .build()); .newBuilder() .maximumSize(projectCacheSize) .softValues() .expireAfterAccess(projectCacheExpiration, TimeUnit.DAYS) .build()); .newBuilder() .maximumSize(projectCacheSize) .softValues() .expireAfterWrite(projectInfoCacheExpiration, TimeUnit.MINUTES) .build());
/** * Constructor. */ TypeCache() { this.lruCache = Caffeine.newBuilder().maximumSize(8192).removalListener((RemovalListener<String, CachedType>) (key, value, cause) -> { if (RemovalCause.SIZE.equals(cause)) { softCache.put(key, value); } }).build(); this.softCache = Caffeine.newBuilder().softValues().build(); }