public class Cache
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
static long | 
DEFAULT_TIME_TO_LIVE
The default time to live time span (5 mins). 
 | 
protected LRU | 
lru
The lru. 
 | 
protected long | 
ttl
The time to live. 
 | 
| Constructor and Description | 
|---|
Cache(int max)
Create a new cache. 
 | 
Cache(int max,
     long ttl)
Create a new cache. 
 | 
Cache(LRU lru,
     long ttl)
Create a new cache. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
canExpire(java.lang.Object key)
Test if an entry can expire. 
 | 
boolean | 
containsKey(java.lang.Object key)
Test if a key is contained. 
 | 
java.lang.Object | 
get(java.lang.Object key,
   long now)
Get data from the cache. 
 | 
void | 
put(java.lang.Object key,
   java.lang.Object value,
   long now)
Put an entry in the cache. 
 | 
void | 
put(java.lang.Object key,
   java.lang.Object value,
   long now,
   long ttl)
Put an entry in the cache. 
 | 
boolean | 
remove(java.lang.Object key)
Remove an entry. 
 | 
int | 
size()
Get the size. 
 | 
public static final long DEFAULT_TIME_TO_LIVE
protected LRU lru
protected long ttl
public Cache(int max)
public Cache(int max,
             long ttl)
public Cache(LRU lru, long ttl)
public void put(java.lang.Object key,
                java.lang.Object value,
                long now)
key - The key.value - The value.now - The current time.public void put(java.lang.Object key,
                java.lang.Object value,
                long now,
                long ttl)
key - The key.value - The value.now - The current time (-1 for never expire).public java.lang.Object get(java.lang.Object key,
                            long now)
key - The key.now - The current time (-1 for never expire).public boolean remove(java.lang.Object key)
key - The key.public boolean containsKey(java.lang.Object key)
key - The key.public boolean canExpire(java.lang.Object key)
key - The key.public int size()