K
- The keyV
- The valuepublic interface Cache<K,V>
Implementation classes can implement a LRU policy, a random one, a MRU one, or any other suitable policy.
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flushes the cached objects from the cache.
|
V |
get(K key)
Returns the object paired with the specified key if it's
present in the cache, otherwise must return null.
|
void |
insert(K key,
V object)
Inserts the specified object into the cache following the
implemented policy.
|
V |
peek(K key)
Returns the object paired with the specified key if it's
present in the cache, otherwise must return null.
|
void |
remove(K key)
Remove the cached object paired with the specified key.
|
void |
setListener(CacheListener<V> listener)
Set the cache listener
|
int |
size()
The cache size
|
V get(K key)
peek(K)
this method not only return whether
the object is present in the cache or not, but also
applies the implemented policy that will "refresh" the cached
object in the cache, because this cached object
was really requested.key
- the key paired with the objectpeek(K)
V peek(K key)
get(K)
.key
- the key paired with the objectget(K)
void insert(K key, V object)
key
- the key paired with the objectobject
- the object to cacheremove(K)
void remove(K key)
key
- the key paired with the objectinsert(K, V)
void flush()
int size()
void setListener(CacheListener<V> listener)
listener
- The listenerCopyright © 2013 IronJacamar (http://www.ironjacamar.org)