ice.net
Class MemoryCache

java.lang.Object
  extended byice.net.MemoryCache
All Implemented Interfaces:
Cache

public class MemoryCache
extends Object
implements Cache

The basic class for caches. Implements a memorycache.


Constructor Summary
MemoryCache()
          Construct a default memorycache.
 
Method Summary
 void clear()
          Clears the cache of any and all entries.
 void clearExpired()
          Check every cache entry and discard the entries which are expired.
 void delete(String url, boolean propFlag)
          Delete a cached entry.
 CachedObject get(String url)
          Get the cached Object referenced by the url parameter.
 long getCurrentSize()
          Returns the collective size of all cached objects in the cache, in bytes.
 long getMaxSize()
          get the maximum number of bytes the cache is allowed to grow to.
 String getName()
          Return the name of the cache.
 boolean has(String url)
          Test if the cache has the supplied url.
 void setExpires(String url, Date date)
          Set the expiry date of the cached object referenced by the url.
 void setManager(CacheManager cmIn)
          Set callback.
 void setMaxSize(long sizeInBytes)
          Set the maximum number of bytes the cache is allowed to grow to.
 void submit(CachedObject cachedObject)
          Submit a CachedObject to the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryCache

public MemoryCache()
Construct a default memorycache. Default size is 1E6 bytes.

Method Detail

setManager

public void setManager(CacheManager cmIn)
Set callback.

Specified by:
setManager in interface Cache

setExpires

public void setExpires(String url,
                       Date date)
Set the expiry date of the cached object referenced by the url.

Specified by:
setExpires in interface Cache

submit

public void submit(CachedObject cachedObject)
Submit a CachedObject to the cache.

Specified by:
submit in interface Cache
See Also:
CacheManager

delete

public void delete(String url,
                   boolean propFlag)
Delete a cached entry. propFlag should be true if entry should be permitted to (possibly) propagate to other caches.

Specified by:
delete in interface Cache
Parameters:
url - The url describing the cache entry which is to be deleted.
propFlag - Boolean value to determine if deleted entry is to be (possibly)redistributed to other caches

has

public boolean has(String url)
Test if the cache has the supplied url.

Specified by:
has in interface Cache

getCurrentSize

public long getCurrentSize()
Returns the collective size of all cached objects in the cache, in bytes.

Specified by:
getCurrentSize in interface Cache

clear

public void clear()
Clears the cache of any and all entries. Entries cleared are NOT passed on to the CacheManager

Specified by:
clear in interface Cache

setMaxSize

public void setMaxSize(long sizeInBytes)
Set the maximum number of bytes the cache is allowed to grow to.

Specified by:
setMaxSize in interface Cache
Parameters:
sizeInBytes - The size in bytes that the cache should be.

getMaxSize

public long getMaxSize()
get the maximum number of bytes the cache is allowed to grow to.

Specified by:
getMaxSize in interface Cache

clearExpired

public void clearExpired()
Check every cache entry and discard the entries which are expired.

Specified by:
clearExpired in interface Cache

get

public CachedObject get(String url)
Get the cached Object referenced by the url parameter.

Specified by:
get in interface Cache
Parameters:
url - The url of the cached object (generated by URL.toString())

getName

public String getName()
Return the name of the cache.

Specified by:
getName in interface Cache