Modifier and Type | Field and Description |
---|---|
protected Map<String,HalResourceCacheEntry> |
cache |
protected int |
capacity |
static Comparator<HalResourceCacheEntry> |
COMPARATOR |
protected long |
secondsToLive |
Constructor and Description |
---|
DefaultHalResourceCache() |
DefaultHalResourceCache(int capacity,
long secondsToLive) |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy cache.
|
protected void |
ensureCapacityLimit() |
protected boolean |
expired(HalResourceCacheEntry entry) |
Object |
get(String id)
Get a resource by id.
|
int |
getCapacity() |
long |
getSecondsToLive() |
void |
put(String id,
Object resource)
Put a resource into the cache.
|
void |
remove(String id) |
void |
setCapacity(int capacity) |
void |
setSecondsToLive(long secondsToLive) |
int |
size() |
public static final Comparator<HalResourceCacheEntry> COMPARATOR
protected int capacity
protected long secondsToLive
protected Map<String,HalResourceCacheEntry> cache
public DefaultHalResourceCache()
public DefaultHalResourceCache(int capacity, long secondsToLive)
public int getCapacity()
public void setCapacity(int capacity)
public long getSecondsToLive()
public void setSecondsToLive(long secondsToLive)
public int size()
public void put(String id, Object resource)
Cache
public void remove(String id)
public void destroy()
Cache
protected void ensureCapacityLimit()
protected boolean expired(HalResourceCacheEntry entry)
Copyright © 2020. All rights reserved.