|
Openfire 3.6.0 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Cache<K,V>
General purpose cache. It stores objects associated with unique keys in memory for fast access. All keys and values added to the cache must implement the Serializable interface. Values may implement the Cacheable interface, which allows the cache to determine object size much more quickly. These restrictions allow a cache to never grow larger than a specified number of bytes and to optionally be distributed over a cluster of servers.
If the cache does grow too large, objects will be removed such that those that are accessed least frequently are removed first. Because expiration happens automatically, the cache makes no gaurantee as to how long an object will remain in cache after it is put in.
Optionally, a maximum lifetime for all objects can be specified. In that case, objects will be deleted from cache after that amount of time, even if they are frequently accessed. This feature is useful if objects put in cache represent data that should be periodically refreshed; for example, information from a database.
All cache operations are thread safe.
Cacheable
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Method Summary | |
---|---|
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 the cache. |
void |
setMaxCacheSize(int maxSize)
Sets the maximum size of the cache in bytes. |
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 the cache |
Methods inherited from interface java.util.Map |
---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Method Detail |
---|
String getName()
void setName(String name)
name
- the name of the cachelong getMaxCacheSize()
void setMaxCacheSize(int maxSize)
maxSize
- the maximum size of the cache in bytes.long getMaxLifetime()
void setMaxLifetime(long maxLifetime)
maxLifetime
- the maximum number of milliseconds before objects are expired.int getCacheSize()
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.
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.
|
Openfire 3.6.0 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |