|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.egothor.cache.staticDynamic.StaticDynamicCache<K,V>
K - type of the keyV - type of the valuepublic class StaticDynamicCache<K,V>
Implementation of Cache that uses a static and a dynamic cache.
| Field Summary | |
|---|---|
static int |
DEFAULT_CAPACITY
Default capacity of the static cache. |
| Constructor Summary | |
|---|---|
StaticDynamicCache(Cache<K,V> dynamicCache)
Constructor for the StaticDynamicCache object. |
|
StaticDynamicCache(Cache<K,V> dynamicCache,
int staticCapacity)
Constructor for the StaticDynamicCache object. |
|
StaticDynamicCache(Resolver<K,V> resolver,
Cache<K,V> dynamicCache)
Constructor for the StaticDynamicCache object. |
|
StaticDynamicCache(Resolver<K,V> resolver,
Cache<K,V> dynamicCache,
int staticCapacity)
Constructor for the StaticDynamicCache object. |
|
| Method Summary | |
|---|---|
int |
capacity()
Returns the maximum number of key->value mappings cache can hold. |
void |
clear()
Remove all key->value mappings from the static and the dynamic cache. |
boolean |
containsKey(K key)
Checks whether the specified key is cached in static or dynamic cache. |
int |
dynamicCapacity()
Returns the capacity of the dynamic cache. |
void |
evict()
Removes a key from the dynamic cache according to its cache eviction policy. |
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. |
Resolver<K,V> |
getResolver()
Gets the current resolver associated with this cache. |
float |
hitRatio()
Returns the hits/requests ratio in percents. |
long |
hits()
Returns the number of all hits. |
java.util.Set<K> |
keySet()
Gets all keys contained in the cache. |
long |
misses()
Returns the number of all misses. |
K |
nextEvicted()
Gets the next key that would be removed from the dynamic cache according to the current cache replacement policy. |
V |
put(K key,
V value)
Adds a new key->value mapping to the cache. |
V |
remove(K key)
Removes the specified key and its value from the cache. |
long |
requests()
Returns the number of all submitted requests |
void |
resetCounters()
Sets hits and misses counters to zero. |
Resolver<K,V> |
setResolver(Resolver<K,V> resolver)
Sets the resolver associated with this cache. |
int |
size()
Returns the number of key->value mappings in the cache. |
int |
staticCapacity()
Returns the capacity of the static 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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_CAPACITY
| Constructor Detail |
|---|
public StaticDynamicCache(Cache<K,V> dynamicCache)
dynamicCache - dynamic cache to use
public StaticDynamicCache(Cache<K,V> dynamicCache,
int staticCapacity)
dynamicCache - dynamic cache to usestaticCapacity - capacity of the static part of the cache
public StaticDynamicCache(Resolver<K,V> resolver,
Cache<K,V> dynamicCache)
resolver - resolver to associate with the cachesdynamicCache - dynamic cache to use
public StaticDynamicCache(Resolver<K,V> resolver,
Cache<K,V> dynamicCache,
int staticCapacity)
resolver - resolver to associate with the cachesdynamicCache - dynamic cache to usestaticCapacity - capacity of the static part of the cache| Method Detail |
|---|
public V put(K key,
V value)
put in interface Cache<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>key - key to get the value for
public V remove(K key)
remove in interface Cache<K,V>key - key to remove from the cache.
public V update(K key,
V value)
update in interface Cache<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>key - key to check
public void clear()
clear in interface Cache<K,V>public java.util.Set<K> keySet()
keySet in interface Cache<K,V>Set of keys contained in the cache.public int size()
size in interface Cache<K,V>public int capacity()
capacity in interface Cache<K,V>public int staticCapacity()
public int dynamicCapacity()
public K nextEvicted()
nextEvicted in interface Cache<K,V>public void evict()
evict in interface Cache<K,V>public float hitRatio()
hitRatio in interface Cache<K,V>public long hits()
hits in interface Cache<K,V>public long misses()
misses in interface Cache<K,V>public long requests()
requests in interface Cache<K,V>public void resetCounters()
resetCounters in interface Cache<K,V>public Resolver<K,V> getResolver()
getResolver in interface Cache<K,V>public Resolver<K,V> setResolver(Resolver<K,V> resolver)
setResolver in interface Cache<K,V>resolver - new resolver we want to associate with this cache.
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||