@Test public void doEviction() { cache.put("a", "b", TimeUnit.MILLISECONDS, 0); cache.put("c", "d", TimeUnit.MILLISECONDS, 0); try { Thread.sleep(3); } catch (InterruptedException e) { } cache.doEviction(); verify(evictionListener).onEviction("a", "b"); verify(evictionListener).onEviction("c", "d"); assertEquals(cache.size(), 0); }
protected void doEviction() { final Set<Entry<K, Pointer>> entries = pointerMap.entrySet(); for (final Entry<K, Pointer> entry : entries) { if (entry.getValue().isExpired()) { final V value = invalidate(entry.getKey()); evictionListener.onEviction(entry.getKey(), value); stats.incrementEvictionCount(); } } }
OffHeapCache extends AbstractSearchableCache<K, V> { protected void doEviction() { final Set<Entry<K, Pointer>> entries = pointerMap.entrySet(); for (final Entry<K, Pointer> entry : entries) { if (entry.getValue().isExpired()) { final V value = invalidate(entry.getKey()); evictionListener.onEviction(entry.getKey(), value); stats.incrementEvictionCount(); } } } }
OffHeapCache extends AbstractSearchableCache<K, V> { protected void doEviction() { final Set<Entry<K, Pointer>> entries = pointerMap.entrySet(); for (final Entry<K, Pointer> entry : entries) { if (entry.getValue().isExpired()) { final V value = invalidate(entry.getKey()); evictionListener.onEviction(entry.getKey(), value); stats.incrementEvictionCount(); } } } OffHeapCache(final String name, final CacheLoader<K, V> cacheLoader,
      final EvictionListener<K, V> evictionListener,
      final IndexHandler<K, V> indexHandler, final OffHeapByteBufferStore byteBufferStore,
      final Serializer<V> serializer,
      final long bufferCleanerPeriod, final float bufferCleanerThreshold,
      final int concurrencyLevel,
      final long evictionPeriod); }
OffHeapCache extends AbstractSearchableCache<K, V> { protected void doEviction() { final Set<Entry<K, Pointer>> entries = pointerMap.entrySet(); for (final Entry<K, Pointer> entry : entries) { if (entry.getValue().isExpired()) { final V value = invalidate(entry.getKey()); evictionListener.onEviction(entry.getKey(), value); stats.incrementEvictionCount(); } } } OffHeapCache(final String name, final CacheLoader<K, V> cacheLoader,
      final EvictionListener<K, V> evictionListener,
      final IndexHandler<K, V> indexHandler, final OffHeapByteBufferStore byteBufferStore,
      final Serializer<V> serializer,
      final long bufferCleanerPeriod, final float bufferCleanerThreshold,
      final int concurrencyLevel,
      final long evictionPeriod); void put(K key, V value); @Override void put(final K key, final V value, final TimeUnit timeUnit, final long duration); V get(K key); V invalidate(K key); boolean contains(K key); void clear(); @Override long size(); @Override CacheStats stats(); }
OffHeapCache extends AbstractSearchableCache<K, V> { protected void doEviction() { final Set<Entry<K, Pointer>> entries = pointerMap.entrySet(); for (final Entry<K, Pointer> entry : entries) { if (entry.getValue().isExpired()) { final V value = invalidate(entry.getKey()); evictionListener.onEviction(entry.getKey(), value); stats.incrementEvictionCount(); } } } OffHeapCache(final String name, final CacheLoader<K, V> cacheLoader,
      final EvictionListener<K, V> evictionListener,
      final IndexHandler<K, V> indexHandler, final OffHeapByteBufferStore byteBufferStore,
      final Serializer<V> serializer,
      final long bufferCleanerPeriod, final float bufferCleanerThreshold,
      final int concurrencyLevel,
      final long evictionPeriod); void put(K key, V value); @Override void put(final K key, final V value, final TimeUnit timeUnit, final long duration); V get(K key); V invalidate(K key); boolean contains(K key); void clear(); @Override long size(); @Override CacheStats stats(); static final long DEFAULT_BUFFER_CLEANER_PERIOD; static final long DEFAULT_EVICTION_PERIOD; static final float DEFAULT_BUFFER_CLEANER_THRESHOLD; static final int DEFAULT_CONCURRENCY_LEVEL; }