public abstract class Cache<K,V>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Cache.CacheVisitor<K,V> |
static class |
Cache.EqualByteArray
Utility class that wraps a byte array and implements the equals()
and hashCode() contract in a way suitable for Maps and caches.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Cache() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
accept(Cache.CacheVisitor<K,V> visitor)
accept a visitor
|
abstract void |
clear()
Remove all entries from the cache.
|
abstract V |
get(java.lang.Object key)
Get a value from the cache.
|
static <K,V> Cache<K,V> |
newHardMemoryCache(int size)
Return a new memory cache with the specified maximum size, unlimited
lifetime for entries, with the values held by standard references.
|
static <K,V> Cache<K,V> |
newHardMemoryCache(int size,
int timeout)
Return a new memory cache with the specified maximum size, the
specified maximum lifetime (in seconds), with the values held
by standard references.
|
static <K,V> Cache<K,V> |
newNullCache()
Return a dummy cache that does nothing.
|
static <K,V> Cache<K,V> |
newSoftMemoryCache(int size)
Return a new memory cache with the specified maximum size, unlimited
lifetime for entries, with the values held by SoftReferences.
|
static <K,V> Cache<K,V> |
newSoftMemoryCache(int size,
int timeout)
Return a new memory cache with the specified maximum size, the
specified maximum lifetime (in seconds), with the values held
by SoftReferences.
|
abstract V |
pull(java.lang.Object key)
Pull an entry from the cache.
|
abstract void |
put(K key,
V value)
Add an entry to the cache.
|
abstract void |
remove(java.lang.Object key)
Remove an entry from the cache.
|
abstract void |
setCapacity(int size)
Set the maximum size.
|
abstract void |
setTimeout(int timeout)
Set the timeout(in seconds).
|
abstract int |
size()
Return the number of currently valid entries in the cache.
|
public abstract int size()
public abstract void clear()
public abstract V get(java.lang.Object key)
public abstract void remove(java.lang.Object key)
public abstract V pull(java.lang.Object key)
public abstract void setCapacity(int size)
public abstract void setTimeout(int timeout)
public abstract void accept(Cache.CacheVisitor<K,V> visitor)
public static <K,V> Cache<K,V> newSoftMemoryCache(int size)
public static <K,V> Cache<K,V> newSoftMemoryCache(int size, int timeout)
public static <K,V> Cache<K,V> newHardMemoryCache(int size)
public static <K,V> Cache<K,V> newNullCache()
public static <K,V> Cache<K,V> newHardMemoryCache(int size, int timeout)