ice.net
Class CacheManager

java.lang.Object
  extended byice.net.CacheManager

public class CacheManager
extends Object

This class manages caches.

Since:
1.4.1
Version:
1.6.0
Author:
Thomas Nøkleby, Jack van Ooststroom

Constructor Summary
CacheManager()
           
CacheManager(CacheManagerSettings cacheManagerSettings)
           
CacheManager(ice.net.HttpSession httpSession)
          Deprecated. As of 1.5.0, replaced by CacheManager(CacheManagerSettings).
 
Method Summary
 void addCache(Cache aCache)
          Add a cache to the CacheManager.
 void clearAllCaches()
          Clear all Caches.
 void clearAllExpired()
          Clear only expired cache entries for every cache.
 boolean clearCache(String cacheName)
          Clear a named cache.
 boolean clearExpired(String cacheName)
          Clear only expired cache entries for a named cache.
 Cache getCache(int cachePriority)
          Return a cache based on priority.
 Cache getCache(String cacheName)
          Returns a named cache.
 InputStream getCachedContent(URL url, ice.net.CacheCallback cacheCallback)
          Returns an inputstream containing the requested URL, or null if the URL was not in the cache or expired.
 int getCacheExpirationBuffer()
          Gets the cache expiration buffer in seconds of this CacheManager.
 int getPriority(Cache c)
          Returns the current priority of the supplied cache, or -1 if no such cache exists.
 boolean isCacheOn()
          Indicate if cache is active or not.
 boolean isExpired(CachedObject cachedObject)
          Deprecated. As of 1.6.0, replaced by CachedObject.isFresh().
 boolean isExpired(long expires, long recieved, long lastModified, long maxAge)
          Deprecated. As of 1.6.0, replaced by CachedObject.isFresh().
 Cache removeCache(String cacheName)
          Remove a cache from the CacheManager.
protected  void removeURL(URL url)
          Remove an url, if it exists, from all registered caches.
 boolean shouldAlwaysRevalidate()
           
 boolean shouldPersistPrivateResponses()
           
 void status()
          Prints out the status (name, maxsize and bytes used) of every cache registered in the CacheManager.
 void submit(byte[] bytes, HttpURLConnection httpUrlConnection)
          Deprecated. As of 1.6.0, replaced by submit(byte[], HttpURLConnection).
 void submit(byte[] bytes, HttpURLConnection httpUrlConnection)
           
 void useCache(boolean choice)
          Turn on/off caching
 void wasDeleted(CachedObject o, Cache c)
          Caches are to call this method for every non-expired object they discard from their internal storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheManager

public CacheManager()

CacheManager

public CacheManager(CacheManagerSettings cacheManagerSettings)
Parameters:
cacheManagerSettings -
Since:
1.5.0

CacheManager

public CacheManager(ice.net.HttpSession httpSession)
Deprecated. As of 1.5.0, replaced by CacheManager(CacheManagerSettings).

Method Detail

getCacheExpirationBuffer

public int getCacheExpirationBuffer()

Gets the cache expiration buffer in seconds of this CacheManager.

Returns:
the cache expiration buffer in seconds.
Since:
1.6.0

shouldAlwaysRevalidate

public boolean shouldAlwaysRevalidate()

shouldPersistPrivateResponses

public boolean shouldPersistPrivateResponses()
Returns:
Since:
1.6.0

getCache

public Cache getCache(int cachePriority)
Return a cache based on priority. Given n caches, priority range is [0,n-1].


addCache

public void addCache(Cache aCache)
Add a cache to the CacheManager.


removeCache

public Cache removeCache(String cacheName)
Remove a cache from the CacheManager.


getPriority

public int getPriority(Cache c)
Returns the current priority of the supplied cache, or -1 if no such cache exists. Given n caches, priority range is [0,n-1], where 0 is the highest priority


getCache

public Cache getCache(String cacheName)
Returns a named cache.


useCache

public void useCache(boolean choice)
Turn on/off caching


isCacheOn

public boolean isCacheOn()
Indicate if cache is active or not.


clearCache

public boolean clearCache(String cacheName)
Clear a named cache.


clearAllCaches

public void clearAllCaches()
Clear all Caches.


clearExpired

public boolean clearExpired(String cacheName)
Clear only expired cache entries for a named cache.


clearAllExpired

public void clearAllExpired()
Clear only expired cache entries for every cache.


removeURL

protected void removeURL(URL url)
Remove an url, if it exists, from all registered caches. The URL will not be moved to other caches.


getCachedContent

public InputStream getCachedContent(URL url,
                                    ice.net.CacheCallback cacheCallback)
Returns an inputstream containing the requested URL, or null if the URL was not in the cache or expired. The first added Cache is queried first.


submit

public void submit(byte[] bytes,
                   HttpURLConnection httpUrlConnection)
Deprecated. As of 1.6.0, replaced by submit(byte[], HttpURLConnection).


submit

public void submit(byte[] bytes,
                   HttpURLConnection httpUrlConnection)

status

public void status()
Prints out the status (name, maxsize and bytes used) of every cache registered in the CacheManager.


isExpired

public boolean isExpired(CachedObject cachedObject)
Deprecated. As of 1.6.0, replaced by CachedObject.isFresh().


isExpired

public boolean isExpired(long expires,
                         long recieved,
                         long lastModified,
                         long maxAge)
Deprecated. As of 1.6.0, replaced by CachedObject.isFresh().


wasDeleted

public void wasDeleted(CachedObject o,
                       Cache c)
Caches are to call this method for every non-expired object they discard from their internal storage.