|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.egothor.cache.AbstractCache<K,V>
org.egothor.cache.multiQueue.MultiQueueCache<K,V>
K
- type of the keyV
- type of the valuepublic class MultiQueueCache<K,V>
Implementation of Cache
that uses the MQ algorithm as an eviction policy.
Field Summary | |
---|---|
static byte |
DEFAULT_NUMBER_OF_QUEUES
Default number of queues the MQ algorithm should use. |
Fields inherited from class org.egothor.cache.AbstractCache |
---|
capacity, DEFAULT_CAPACITY, hits, misses, resolver |
Constructor Summary | |
---|---|
MultiQueueCache()
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(int capacity)
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(int capacity,
int outCapacity)
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(int capacity,
int outCapacity,
byte numberOfQueues)
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(int capacity,
int outCapacity,
byte numberOfQueues,
MultiQueueFunction queueFunction)
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(Resolver<K,V> resolver)
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(Resolver<K,V> resolver,
int capacity)
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(Resolver<K,V> resolver,
int capacity,
int outCapacity)
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(Resolver<K,V> resolver,
int capacity,
int outCapacity,
byte numberOfQueues)
Constructor for the MultiQueueCache object. |
|
MultiQueueCache(Resolver<K,V> resolver,
int capacity,
int outCapacity,
byte numberOfQueues,
MultiQueueFunction queueFunction)
Constructor for the MultiQueueCache object. |
Method Summary | |
---|---|
void |
clear()
Removes all key->value mappings from the cache and cleans all queues. |
boolean |
containsKey(K key)
Checks whether the specified key is cached. |
void |
evict()
Removes the LRU item of the first LRU queue from the cache. |
V |
get(K key)
Gets the value associated with the specified key from the cache if a mapping exists, or the value returned by the resolver. |
java.util.Set<K> |
keySet()
Gets all keys contained in the cache. |
K |
nextEvicted()
Gets the LRU item of the first non-empty LRU queue. |
int |
numberOfQueues()
Returns the number of queues used by the MQ algorithm. |
int |
outCapacity()
Returns the capacity of the history QOut queue. |
V |
put(K key,
V value)
Adds a new key->value mapping to the cache. |
MultiQueueFunction |
queueFunction()
Gets the class that is used to compute the queue number. |
V |
remove(K key)
Removes the specified key and its value from the cache. |
int |
size()
Returns the number of key->value mappings in the cache. |
java.lang.String |
toString()
Returns a text representation of the cache. |
V |
update(K key,
V value)
Updates the value associated with the specified key in the cache if a mapping exists for the key. |
Methods inherited from class org.egothor.cache.AbstractCache |
---|
capacity, getResolver, hitRatio, hits, misses, requests, resetCounters, setResolver |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static byte DEFAULT_NUMBER_OF_QUEUES
Constructor Detail |
---|
public MultiQueueCache()
public MultiQueueCache(int capacity)
capacity
- capacity of the cachepublic MultiQueueCache(int capacity, int outCapacity)
capacity
- capacity of the cacheoutCapacity
- capacity of the history QOut queuepublic MultiQueueCache(int capacity, int outCapacity, byte numberOfQueues)
capacity
- capacity of the cacheoutCapacity
- capacity of the history QOut queuenumberOfQueues
- number of queues that should be used by the MQ algorithmpublic MultiQueueCache(int capacity, int outCapacity, byte numberOfQueues, MultiQueueFunction queueFunction)
capacity
- capacity of the cacheoutCapacity
- capacity of the history QOut queuenumberOfQueues
- number of queues that should be used by the MQ algorithmqueueFunction
- queue function that should be used by the MQ algorithmpublic MultiQueueCache(Resolver<K,V> resolver)
resolver
- resolver to associate with the cachepublic MultiQueueCache(Resolver<K,V> resolver, int capacity)
resolver
- resolver to associate with the cachecapacity
- capacity of the cachepublic MultiQueueCache(Resolver<K,V> resolver, int capacity, int outCapacity)
resolver
- resolver to associate with the cachecapacity
- capacity of the cacheoutCapacity
- capacity of the history QOut queuepublic MultiQueueCache(Resolver<K,V> resolver, int capacity, int outCapacity, byte numberOfQueues)
resolver
- resolver to associate with the cachecapacity
- capacity of the cacheoutCapacity
- capacity of the history QOut queuenumberOfQueues
- number of queues that should be used by the MQ algorithmpublic MultiQueueCache(Resolver<K,V> resolver, int capacity, int outCapacity, byte numberOfQueues, MultiQueueFunction queueFunction)
resolver
- resolver to associate with the cachecapacity
- capacity of the cacheoutCapacity
- capacity of the history QOut queuenumberOfQueues
- number of queues that should be used by the MQ algorithmqueueFunction
- queue function that should be used by the MQ algorithmMethod Detail |
---|
public V put(K key, V value)
put
in interface Cache<K,V>
put
in class AbstractCache<K,V>
key
- key to add to the cachevalue
- value to map the key on
public V get(K key)
get
in interface Cache<K,V>
get
in class AbstractCache<K,V>
key
- key to get the value for
public V remove(K key)
remove
in interface Cache<K,V>
remove
in class AbstractCache<K,V>
key
- key to remove from the cache.
public V update(K key, V value)
update
in interface Cache<K,V>
update
in class AbstractCache<K,V>
key
- key to change the value forvalue
- new value associated with the key
public boolean containsKey(K key)
containsKey
in interface Cache<K,V>
containsKey
in class AbstractCache<K,V>
key
- key to check
public void clear()
public java.util.Set<K> keySet()
Set
of keys contained in the cache.public int size()
size
in interface Cache<K,V>
size
in class AbstractCache<K,V>
public K nextEvicted()
nextEvicted
in interface Cache<K,V>
nextEvicted
in class AbstractCache<K,V>
public void evict()
evict
in interface Cache<K,V>
evict
in class AbstractCache<K,V>
public int outCapacity()
public int numberOfQueues()
public MultiQueueFunction queueFunction()
public java.lang.String toString()
toString
in class AbstractCache<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |