Package org.apache.cassandra.cache
Class CaffeineCache<K extends IMeasurableMemory,V extends IMeasurableMemory>
java.lang.Object
org.apache.cassandra.cache.CaffeineCache<K,V>
public class CaffeineCache<K extends IMeasurableMemory,V extends IMeasurableMemory>
extends Object
implements ICache<K,V>
An adapter from a Caffeine cache to the ICache interface. This provides an on-heap cache using
the W-TinyLFU eviction policy (http://arxiv.org/pdf/1512.00727.pdf), which has a higher hit rate
than an LRU.
-
Method Summary
Modifier and TypeMethodDescriptionlongcapacity()voidclear()booleancontainsKey(K key) static <K extends IMeasurableMemory,V extends IMeasurableMemory>
CaffeineCache<K,V> create(long weightedCapacity) static <K extends IMeasurableMemory,V extends IMeasurableMemory>
CaffeineCache<K,V> create(long weightedCapacity, com.github.benmanes.caffeine.cache.Weigher<K, V> weigher) Initialize a cache with initial capacity with weightedCapacityhotKeyIterator(int n) booleanisEmpty()voidbooleanputIfAbsent(K key, V value) voidbooleanvoidsetCapacity(long capacity) intsize()long
-
Method Details
-
create
public static <K extends IMeasurableMemory,V extends IMeasurableMemory> CaffeineCache<K,V> create(long weightedCapacity, com.github.benmanes.caffeine.cache.Weigher<K, V> weigher) Initialize a cache with initial capacity with weightedCapacity -
create
public static <K extends IMeasurableMemory,V extends IMeasurableMemory> CaffeineCache<K,V> create(long weightedCapacity) -
capacity
public long capacity() -
setCapacity
public void setCapacity(long capacity) - Specified by:
setCapacityin interfaceCacheSize
-
isEmpty
public boolean isEmpty() -
size
public int size() -
weightedSize
public long weightedSize()- Specified by:
weightedSizein interfaceCacheSize
-
clear
public void clear()- Specified by:
clearin interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-
get
- Specified by:
getin interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-
put
- Specified by:
putin interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-
replace
- Specified by:
replacein interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-
remove
- Specified by:
removein interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-
keyIterator
- Specified by:
keyIteratorin interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-
hotKeyIterator
- Specified by:
hotKeyIteratorin interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-
containsKey
- Specified by:
containsKeyin interfaceICache<K extends IMeasurableMemory,V extends IMeasurableMemory>
-