|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.extensions.surf.cache.BasicCache<K>
public class BasicCache<K>
This is an implementation of a purely in-memory cache that uses a HashMap to provide a basic form of caching. This class is thread safe for concurrent usage of the cache.
Field Summary | |
---|---|
protected HashMap<String,CacheItem<K>> |
cache
|
protected long |
timeout
|
Constructor Summary | |
---|---|
BasicCache(long timeout)
Instantiates a new basic cache. |
|
BasicCache(long timeout,
int size)
Instantiates a new basic cache. |
Method Summary | |
---|---|
K |
get(String key)
Gets content stored in the cache |
void |
invalidate()
Invalidates the cache |
Set<String> |
keys()
Returns keys for the items in the cache |
void |
put(String key,
K obj)
Places content into the cache (with default timeout) |
void |
put(String key,
K obj,
long timeout)
Places content into the cache |
void |
remove(String key)
Removes a content object from the cache. |
Collection<CacheItem<K>> |
values()
Returns the values for the items in the cache |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final HashMap<String,CacheItem<K>> cache
protected final long timeout
Constructor Detail |
---|
public BasicCache(long timeout)
timeout
- the timeoutpublic BasicCache(long timeout, int size)
timeout
- the timeoutsize
- Cache sizeMethod Detail |
---|
public K get(String key)
ContentCache
get
in interface ContentCache<K>
key
- the key
public void remove(String key)
ContentCache
remove
in interface ContentCache<K>
key
- the keypublic void put(String key, K obj)
ContentCache
put
in interface ContentCache<K>
key
- the keyobj
- the objpublic void put(String key, K obj, long timeout)
ContentCache
put
in interface ContentCache<K>
key
- the keyobj
- the objtimeout
- the timeout in millisecondspublic void invalidate()
ContentCache
invalidate
in interface ContentCache<K>
public Collection<CacheItem<K>> values()
public Set<String> keys()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |