Package net.didion.jwnl.util.cache
Interface Cache
- All Known Implementing Classes:
AbstractCachingDictionary.ObservableCache
,LRUCache
public interface Cache
A
Cache
is a collection of values that are indexed by keys and that are stored for an
unspecified amount of time (which the implementor of Cache
may further specify).-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Remove all values stored in this cache.If key was used in a previous call toput
, this call may return the value of that call.int
Returns the maximum number of elements the cache can hold.int
getSize()
Returns the current size of the cache.Store value in the cache, indexed by key.Remotes the object associated with key and returns that object.int
setCapacity
(int capacity) Set the maximum number of elements the cache can hold.
-
Method Details
-
put
Store value in the cache, indexed by key. This operation makes it likely, although not certain, that a subsquent call toget
with the same (equal
) key will retrieve the same (==
) value.Multiple calls to
put
with the same key and value are idempotent. A set of calls toput
with the same key but different values has only the affect of the last call (assuming there were no intervening calls toget
). -
get
If key was used in a previous call toput
, this call may return the value of that call. Otherwise it returnsnull
. -
remove
Remotes the object associated with key and returns that object. -
getCapacity
int getCapacity()Returns the maximum number of elements the cache can hold. -
setCapacity
int setCapacity(int capacity) Set the maximum number of elements the cache can hold. -
getSize
int getSize()Returns the current size of the cache. -
clear
void clear()Remove all values stored in this cache. Subsequent calls toget
will returnnull
.
-