public class DefaultCache<K extends Serializable,V extends Serializable> extends Object implements Cache<K,V>
To get an object from cache, a hash lookup is performed to get a reference to the CacheObject that wraps the real object we are looking for. The object is subsequently moved to the front of the accessed linked list and any necessary cache cleanups are performed. Cache deletion and expiration is performed as needed.
| Modifier and Type | Field and Description |
|---|---|
protected Map<K,org.jivesoftware.util.cache.DefaultCache.CacheObject<V>> |
map
The map the keys and values are stored in.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet()
IMPORTANT: Unlike the standard
Map.entrySet() implementation, the set returned from
this method cannot be modified. |
V |
get(Object key) |
long |
getCacheCulls(Duration duration) |
long |
getCacheHits()
Returns the number of cache hits.
|
long |
getCacheMisses()
Returns the number of cache misses.
|
int |
getCacheSize()
Returns the size of the cache contents in bytes.
|
long |
getMaxCacheSize()
Returns the maximum size of the cache (in bytes).
|
long |
getMaxLifetime()
Returns the maximum number of milliseconds that any object can live
in cache.
|
String |
getName()
Returns the name of this cache.
|
boolean |
isEmpty() |
Set<K> |
keySet()
IMPORTANT: Unlike the standard
Map.keySet() implementation, the set returned from
this method cannot be modified. |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> map) |
V |
remove(Object key) |
void |
setMaxCacheSize(int maxCacheSize)
Sets the maximum size of the cache.
|
void |
setMaxLifetime(long maxLifetime)
Sets the maximum number of milliseconds that any object can live
in cache.
|
void |
setName(String name)
Sets the name of this cache.
|
int |
size() |
Collection<V> |
values()
IMPORTANT: Unlike the standard
Map.values() implementation, the collection returned from
this method cannot be modified. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllprotected Map<K extends Serializable,org.jivesoftware.util.cache.DefaultCache.CacheObject<V extends Serializable>> map
public V put(K key, V value)
put in interface Map<K extends Serializable,V extends Serializable>public V get(Object key)
get in interface Map<K extends Serializable,V extends Serializable>public V remove(Object key)
remove in interface Map<K extends Serializable,V extends Serializable>public void clear()
clear in interface Map<K extends Serializable,V extends Serializable>public int size()
size in interface Map<K extends Serializable,V extends Serializable>public boolean isEmpty()
isEmpty in interface Map<K extends Serializable,V extends Serializable>public Collection<V> values()
CacheMap.values() implementation, the collection returned from
this method cannot be modified.values in interface Map<K extends Serializable,V extends Serializable>values in interface Cache<K extends Serializable,V extends Serializable>public boolean containsKey(Object key)
containsKey in interface Map<K extends Serializable,V extends Serializable>public void putAll(Map<? extends K,? extends V> map)
putAll in interface Map<K extends Serializable,V extends Serializable>public boolean containsValue(Object value)
containsValue in interface Map<K extends Serializable,V extends Serializable>public Set<Map.Entry<K,V>> entrySet()
CacheMap.entrySet() implementation, the set returned from
this method cannot be modified.entrySet in interface Map<K extends Serializable,V extends Serializable>entrySet in interface Cache<K extends Serializable,V extends Serializable>public Set<K> keySet()
CacheMap.keySet() implementation, the set returned from
this method cannot be modified.keySet in interface Map<K extends Serializable,V extends Serializable>keySet in interface Cache<K extends Serializable,V extends Serializable>public String getName()
getName in interface Cache<K extends Serializable,V extends Serializable>public void setName(String name)
setName in interface Cache<K extends Serializable,V extends Serializable>name - the name of this cache.public long getCacheHits()
Keeping track of cache hits and misses lets one measure how efficient the cache is; the higher the percentage of hits, the more efficient.
getCacheHits in interface Cache<K extends Serializable,V extends Serializable>public long getCacheMisses()
Keeping track of cache hits and misses lets one measure how efficient the cache is; the higher the percentage of hits, the more efficient.
getCacheMisses in interface Cache<K extends Serializable,V extends Serializable>public int getCacheSize()
getCacheSize in interface Cache<K extends Serializable,V extends Serializable>public long getMaxCacheSize()
getMaxCacheSize in interface Cache<K extends Serializable,V extends Serializable>public void setMaxCacheSize(int maxCacheSize)
setMaxCacheSize in interface Cache<K extends Serializable,V extends Serializable>maxCacheSize - the maximum size of this cache (-1 indicates unlimited max size).public long getMaxLifetime()
getMaxLifetime in interface Cache<K extends Serializable,V extends Serializable>public void setMaxLifetime(long maxLifetime)
setMaxLifetime in interface Cache<K extends Serializable,V extends Serializable>maxLifetime - the maximum number of milliseconds before objects are expired.public long getCacheCulls(Duration duration)
Copyright © 2003–2019 Ignite Realtime. All rights reserved.