|
NASA World Wind | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MemoryCache
Nested Class Summary | |
---|---|
static interface |
MemoryCache.CacheListener
Provides the interface for cache clients to be notified of key events. |
Method Summary | |
---|---|
boolean |
add(Object key,
Cacheable clientObject)
Attempts to add the Cacheable object referenced by the key. |
boolean |
add(Object key,
Object clientObject,
long objectSize)
Attempts to add the object clientObject , with size objectSize and referred to by
key to the cache. |
void |
addCacheListener(MemoryCache.CacheListener listener)
Adds a new cacheListener , which will be sent notification whenever an entry is removed from the
cache. |
void |
clear()
Empties the cache. |
boolean |
contains(Object key)
Discovers whether or not this cache contains the object referenced by key. |
long |
getCapacity()
Retrieves the maximum size of the cache in bytes. |
long |
getFreeCapacity()
Retrieves the available space for storing new items. |
Set<Object> |
getKeySet()
retrieve an unordered Set of the keys of the objects in this MemoryCache . |
long |
getLowWater()
Retrieves the low water value of the MemoryCache . |
String |
getName()
|
int |
getNumObjects()
Retrieve the number of items stored in the MemoryCache . |
Object |
getObject(Object key)
Retrieves the requested item from the cache. |
long |
getUsedCapacity()
Retrieves the amount of used MemoryCache space. |
void |
remove(Object key)
Remove an object from the MemoryCache referenced by key . |
void |
removeCacheListener(MemoryCache.CacheListener listener)
Removes a CacheListener , notifications of events will no longer be sent to this listener. |
void |
setCapacity(long capacity)
Sets the maximum capacity for this cache in bytes. |
void |
setLowWater(long loWater)
Sets the new low water capacity value for this MemoryCache . |
void |
setName(String name)
|
Method Detail |
---|
boolean add(Object key, Cacheable clientObject)
Cacheable
object referenced by the key. No explicit size value is required as
this method queries the Cacheable to discover the size.
This method should be declared synchronized
when it is implemented.
key
- clientObject
-
Cacheable
boolean add(Object key, Object clientObject, long objectSize)
clientObject
, with size objectSize
and referred to by
key
to the cache. objectSize
is the size in bytes, but is not checked for accuracy.
Returns whether or not the add was successful.
Note that the size passed in may be used, rather than the real size of the object. In some implementations, the
accuracy of the space used calls will depend on the collection of these sizes, rather than actual size.
This method should be declared synchronized
when it is implemented.
key
- an object used to reference the cached itemclientObject
- the item to be cachedobjectSize
- the size of the item in bytes.
void addCacheListener(MemoryCache.CacheListener listener)
cacheListener
, which will be sent notification whenever an entry is removed from the
cache.
listener
- the new MemoryCache.CacheListener
void clear()
clear()
on a MemoryCache
, calls relating to used
capacity and number of items should return zero and the free capacity should be the maximum capacity.
This method should be declared synchronized
when it is implemented and should notify all
CacheListener
s of entries removed.
boolean contains(Object key)
key. Currently no interface exists
to discover if an object resides in the cache by referencing itself.
- Parameters:
key
- the key which the object is referenced by.
- Returns:
- true if the key is found in the cache, false otherwise.
long getCapacity()
MemoryCache
in bytes.long getFreeCapacity()
Set<Object> getKeySet()
Set
of the keys of the objects in this MemoryCache
.
Set
containing all the keys in the cache.long getLowWater()
MemoryCache
. When a MemoryCache
runs out of free
space, it must remove some items if it wishes to add any more. It continues removing items until the low water
level is reached. Not every MemoryCache
necessarily uses the low water system, so this may not
return a useful value.
MemoryCache
.String getName()
int getNumObjects()
MemoryCache
.
Object getObject(Object key)
key
is null or the item is not found, this method
returns null.
key
- an Object
used to represent the item to retrieve
Object
if found, null otherwiselong getUsedCapacity()
MemoryCache
space. The value returned is in bytes.
void remove(Object key)
key
. If the object is already absent, this
method simply returns without indicating the absence.
key
- an Object
used to represent the item to remove.void removeCacheListener(MemoryCache.CacheListener listener)
CacheListener
, notifications of events will no longer be sent to this listener.
listener
- void setCapacity(long capacity)
cache
in bytes. This capacity has no impact on the number of
items stored in the MemoryCache
, except that every item must have a positive size. Generally the
used capacity is the total of the sizes of all stored items.
capacity
- the new capacity in bytesvoid setLowWater(long loWater)
MemoryCache
. When a MemoryCache
runs out
of free space, it must remove some items if it wishes to add any more. It continues removing items until the low
water level is reached. Not every MemoryCache
necessarily uses the low water system, so this method
may not have any actual effect in some implementations.
loWater
- the new low water value in bytesvoid setName(String name)
|
NASA World Wind | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |