ice.net
Class FileCache

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

public class FileCache
extends Object
implements Cache

A basic class for caches, implements a Filecache. The default directory to place files in is './cache'


Constructor Summary
FileCache(String pathIn)
          Construct an empty FileCache which uses the path specified.
 
Method Summary
 void clear()
          Remove all cached entries in the cache.
 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 approximate number of bytes of cached object in the cache.
 String getDirectory()
          get directory in which the cached files should be put.
 long getMaxSize()
          Get the maximum number of bytes the cache is allowed to grow to.
 String getName()
          Returns the name of the cache.
 boolean has(String url)
          Test if the cache has the supplied url.
 void setDirectory(String pathIn)
          Set directory in which the cached files should be put.
 void setExpires(String url, Date date)
          Set the expiry date of the cached object referenced by the url.
 void setManager(CacheManager cmIn)
          Set the manager 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

FileCache

public FileCache(String pathIn)
          throws ICEException
Construct an empty FileCache which uses the path specified. The cache will create files named CacheFileXXXX.ice, one file per object and use the a file called dictionary.ice as index.

Method Detail

setManager

public void setManager(CacheManager cmIn)
Set the manager callback.

Specified by:
setManager in interface Cache
Parameters:
cmIn - instance of the CacheManager callback

submit

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

Specified by:
submit in interface Cache
Parameters:
cachedObject - the instance of a cachedObject to cache
See Also:
CacheManager

has

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

Specified by:
has in interface Cache
Parameters:
url - The URL to test
Returns:
true if the FileCache has an entry for the URL

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

setDirectory

public void setDirectory(String pathIn)
                  throws ICEException
Set directory in which the cached files should be put. If the directory is invalid

Throws:
ICEException

getDirectory

public String getDirectory()
get directory in which the cached files should be put.


getCurrentSize

public long getCurrentSize()
Returns the approximate number of bytes of cached object in the cache.

Specified by:
getCurrentSize in interface Cache

clear

public void clear()
Remove all cached entries in the cache.

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

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

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 item to retrieve
Returns:
The item, or null if the item does not exist

getName

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

Specified by:
getName in interface Cache