Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CAPACITY
Default capacity of the static cache.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
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.
|
public static final int DEFAULT_CAPACITY
public StaticDynamicCache(Cache<K,V> dynamicCache)
dynamicCache
- dynamic cache to usepublic StaticDynamicCache(Cache<K,V> dynamicCache, int staticCapacity)
dynamicCache
- dynamic cache to usestaticCapacity
- capacity of the static part of the cachepublic StaticDynamicCache(Resolver<K,V> resolver, Cache<K,V> dynamicCache)
resolver
- resolver to associate with the cachesdynamicCache
- dynamic cache to usepublic 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 cachepublic V put(K key, V value)
public V get(K key)
public V update(K key, V value)
public boolean containsKey(K key)
containsKey
in interface Cache<K,V>
key
- key to checkpublic void clear()
public int size()
public int capacity()
public int staticCapacity()
public int dynamicCapacity()
public K nextEvicted()
nextEvicted
in interface Cache<K,V>
public void evict()
public float hitRatio()
public long hits()
public long misses()
public long requests()
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.Copyright © 2016 Egothor. All Rights Reserved.