public interface Cache
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).Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all values stored in this cache.
|
Object |
get(Object key)
If key was used in a previous call to
put , this call may
return the value of that call. |
int |
getCapacity()
Returns the maximum number of elements the cache can hold.
|
int |
getSize()
Returns the current size of the cache.
|
Object |
put(Object key,
Object value)
Store value in the cache, indexed by key.
|
Object |
remove(Object 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.
|
Object put(Object key, Object value)
get
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 to put
with the same key but
different values has only the affect of the last call (assuming there were
no intervening calls to get
).
Object get(Object key)
put
, this call may
return the value of that call. Otherwise it returns null
.int getCapacity()
int setCapacity(int capacity)
int getSize()
void clear()
get
will return null
.Copyright © 2015. All rights reserved.