private void initCapacityEvictionPolicyFromConfig(final TimestampedValue timestampedValue) { if (isCapacityEvictionEnabled()) { // use CapacityEvictionPolicyData.Factory in config to create a new one if its not an instance of the config's // factory CapacityEvictionPolicyData current = timestampedValue.getCapacityEvictionPolicyData(); if (!getConfig().getCapacityEvictionPolicyDataFactory().isProductOfFactory(current)) { CapacityEvictionPolicyData cep = getConfig().getCapacityEvictionPolicyDataFactory() .newCapacityEvictionPolicyData(); timestampedValue.setCapacityEvictionPolicyData(cep); } } }
private boolean incrementEvictionCounter() { evictionCount++; boolean isTimeForOrphanEviction = evictionCount >= config.getOrphanEvictionPeriod(); if (isTimeForOrphanEviction) { evictionCount = 0; } return isTimeForOrphanEviction; }
public <K, V> DistributedCache<K, V> newCache() { final MutableConfig copyConfig = new MutableConfig(this.name, this.loggingEnabled, this.maxTTISeconds, this.maxTTLSeconds, this.orphanEvictionEnabled, this.orphanEvictionPeriod, this.targetMaxInMemoryCount, this.targetMaxTotalCount, this.capacityEvictionPolicyDataFactory); if (Terracotta.isActive()) { return new TerracottaDistributedCache<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
/** * Constructs a wrapper around the given entry, and it's serialized state. * * @param deserialized cache entry * @param serialized serialized form * @param timeSource source for timestamps */ public SerializedEntry(final T deserialized, final byte[] serialized, final TimeSource timeSource) { this(deserialized, serialized, timeSource.now()); }
/** * Return the value from a possibly null entry. * * @param entry An entry, which may be null * @return The value for entry or null if the entry is null */ private V getValueSafe(final TimestampedValue<V> entry) { return entry == null ? null : entry.getValue(); }
public void clearLocalCache() { if (data instanceof LocallyCacheable) { ((LocallyCacheable) data).clearLocalCache(); } }
private void notifyElementEvicted(Object key) { for (CacheEvictionListener listener : evictionListeners) { // always notify with null value for DCV2 listener.evicted(key, null); } }
private void initCapacityEvictionPolicyFromConfig(final TimestampedValue timestampedValue) { if (isCapacityEvictionEnabled()) { // use CapacityEvictionPolicyData.Factory in config to create a new one if its not an instance of the config's // factory CapacityEvictionPolicyData current = timestampedValue.getCapacityEvictionPolicyData(); if (!getConfig().getCapacityEvictionPolicyDataFactory().isProductOfFactory(current)) { CapacityEvictionPolicyData cep = getConfig().getCapacityEvictionPolicyDataFactory() .newCapacityEvictionPolicyData(); timestampedValue.setCapacityEvictionPolicyData(cep); } } }
public <K, V> DistributedCache<K, V> newCache() { final MutableConfig copyConfig = new MutableConfig(this.name, this.loggingEnabled, this.maxTTISeconds, this.maxTTLSeconds, this.orphanEvictionEnabled, this.orphanEvictionPeriod, this.targetMaxInMemoryCount, this.targetMaxTotalCount, this.capacityEvictionPolicyDataFactory); if (Terracotta.isActive()) { return new TerracottaDistributedCache<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
private boolean incrementEvictionCounter() { evictionCount++; boolean isTimeForOrphanEviction = evictionCount >= config.getOrphanEvictionPeriod(); if (isTimeForOrphanEviction) { evictionCount = 0; } return isTimeForOrphanEviction; }
/** * This method should always be called instead of System.currentTimeMillis() so that time can be controlled by the * TimeSource. * * @return The current time according to the TimeSource */ private int getTime() { return this.timeSource.now(); }
/** * Return the value from a possibly null entry. * * @param entry An entry, which may be null * @return The value for entry or null if the entry is null */ private V getValueSafe(final TimestampedValue<V> entry) { return entry == null ? null : entry.getValue(); }
public void clearLocalCache() { for (final ClusteredMap<K, V> e : this.storeList) { if (e instanceof LocallyCacheable) { ((LocallyCacheable) e).clearLocalCache(); } } }
private void initCapacityEvictionPolicyFromConfig(final TimestampedValue timestampedValue) { if (isCapacityEvictionEnabled()) { // use CapacityEvictionPolicyData.Factory in config to create a new one if its not an instance of the config's // factory CapacityEvictionPolicyData current = timestampedValue.getCapacityEvictionPolicyData(); if (!getConfig().getCapacityEvictionPolicyDataFactory().isProductOfFactory(current)) { CapacityEvictionPolicyData cep = getConfig().getCapacityEvictionPolicyDataFactory() .newCapacityEvictionPolicyData(); timestampedValue.setCapacityEvictionPolicyData(cep); } } }
public <K, V> DistributedCache<K, V> newCache() { final MutableConfig copyConfig = new MutableConfig(this.name, this.loggingEnabled, this.maxTTISeconds, this.maxTTLSeconds, this.orphanEvictionEnabled, this.orphanEvictionPeriod, this.targetMaxInMemoryCount, this.targetMaxTotalCount, this.capacityEvictionPolicyDataFactory); if (Terracotta.isActive()) { return new TerracottaDistributedCache<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
/** * Constructs a wrapper around the given entry, and it's serialized state. * * @param deserialized cache entry * @param serialized serialized form * @param timeSource source for timestamps */ public SerializedEntry(final T deserialized, final byte[] serialized, final TimeSource timeSource) { this(deserialized, serialized, timeSource.now()); }
public void clearLocalCache() { for (final ClusteredMap<K, V> e : this.storeList) { if (e instanceof LocallyCacheable) { ((LocallyCacheable) e).clearLocalCache(); } } }