K
- type of the keyV
- type of the valuepublic abstract class AbstractCache<K,V> extends Object implements Cache<K,V>
Cache
that provides some common methods for cache classes.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CAPACITY
Default capacity of the cache if no explicit capacity is provided.
|
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Returns the maximum number of key-value mappings for this cache.
|
abstract boolean |
containsKey(K key)
Checks whether the specified key is cached.
|
abstract void |
evict()
Removes the next key from the cache according to the current cache replacement policy.
|
V |
get(K key)
Checks whether key parameter is not null.
|
Resolver<K,V> |
getResolver()
Gets the current resolver associated with this cache.
|
float |
hitRatio()
Computes the hits/requests ratio in percents.
|
long |
hits()
Returns the number of all hits.
|
long |
misses()
Returns the number of all misses.
|
abstract K |
nextEvicted()
Gets the next key that would be removed from the cache according to the current cache replacement policy.
|
V |
put(K key,
V value)
Checks whether key and value parameters are not null.
|
V |
remove(K key)
Checks whether key parameter is not null.
|
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.
|
abstract int |
size()
Returns the number of key-value mappings in the cache.
|
abstract String |
toString() |
V |
update(K key,
V value)
Checks whether key and value parameters are not null.
|
public static final int DEFAULT_CAPACITY
public V put(K key, V value)
public V update(K key, V value)
public abstract boolean containsKey(K key)
Cache
containsKey
in interface Cache<K,V>
key
- key to checkpublic abstract int size()
Cache
public abstract K nextEvicted()
Cache
nextEvicted
in interface Cache<K,V>
public abstract void evict()
Cache
public float hitRatio()
public long hits()
public long misses()
public long requests()
public int capacity()
public void resetCounters()
resetCounters
in interface Cache<K,V>
public Resolver<K,V> getResolver()
getResolver
in interface Cache<K,V>
Copyright © 2016 Egothor. All Rights Reserved.