public class Cache extends Object
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_TIME_TO_LIVE
The default time to live time span (5 mins).
|
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(Object key)
Test if an entry can expire.
|
boolean |
containsKey(Object key)
Test if a key is contained.
|
Object |
get(Object key,
long now)
Get data from the cache.
|
void |
put(Object key,
Object value,
long now)
Put an entry in the cache.
|
void |
put(Object key,
Object value,
long now,
long ttl)
Put an entry in the cache.
|
boolean |
remove(Object key)
Remove an entry.
|
int |
size()
Get the size.
|
public static final long DEFAULT_TIME_TO_LIVE
public Cache(int max)
public Cache(int max, long ttl)
public Cache(LRU lru, long ttl)
public void put(Object key, Object value, long now)
key
- The key.value
- The value.now
- The current time.public void put(Object key, Object value, long now, long ttl)
key
- The key.value
- The value.now
- The current time (-1 for never expire).public Object get(Object key, long now)
key
- The key.now
- The current time (-1 for never expire).public boolean remove(Object key)
key
- The key.public boolean containsKey(Object key)
key
- The key.public boolean canExpire(Object key)
key
- The key.public int size()
Copyright © 2013. All Rights Reserved.