|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.util.url.URLCache
Helper class for caching fetched URLs. A more advanced implementation of com.arsdigita.util.Cache which rather than being capacity limited in terms of number of stored keys, it is limited according to memory usage.
Field Summary | |
static int |
FIFTEEN_MINUTES
|
Constructor Summary | |
URLCache()
Create a new URLCache. |
|
URLCache(long size)
Create a new URLCache with a maximum size of size characters. |
|
URLCache(long size,
long expiryTime)
Create a new URLCache with a maximum size of size characters. |
Method Summary | |
long |
getCurrentSize()
|
long |
getDefaultExpiryTime()
Returns default expiry time for cached items. |
long |
getMaxSize()
Returns max size - Maximum memory usage allowed for the data stored in the cache. |
Collection |
getURLS()
Utility method to return all URLs currently in the cache. |
void |
purge(String url)
removes a url from the cache |
void |
purgeAll()
Purges the entire cache. |
void |
purgeExpired()
Immediately removes any expired entries from the cache. |
String |
retrieve(String url)
Deprecated. use retrieveData(String url) |
URLData |
retrieveData(String url)
retrieves a url from the cache, returning null if not present or it has expired. |
void |
setDefaultExpiryTime(long defaultExpiryTime)
Sets default expiry time for cached items. |
void |
setMaxSize(long maxSize)
Sets max size - Maximum memory usage allowed for the data stored in the cache. |
void |
store(String url,
String data)
Deprecated. use store(String url, URLData data) |
void |
store(String url,
String data,
long expiry)
Deprecated. use store(String url, URLData data, long expiry) |
void |
store(String url,
URLData data)
Stores data for a url in the cache. |
void |
store(String url,
URLData data,
long expiry)
Stores data for a url in the cache. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FIFTEEN_MINUTES
Constructor Detail |
public URLCache()
public URLCache(long size)
size
- cache size in characterspublic URLCache(long size, long expiryTime)
Also allows an expiration time to be set; items in the cache that are older than that time will be evicted.
size
- cache size in charactersexpiryTime
- default expiry time for cached items. When
retrieving an item, if its age exceeds expiry time, then it will be
discarded.Method Detail |
public long getCurrentSize()
public long getMaxSize()
public Collection getURLS()
public void setMaxSize(long maxSize)
maxSize
- - Maximum memory usage allowed for the data stored in
the cache. When exceeded, least recently used items are evicted until
there is sufficient space for the new item.public long getDefaultExpiryTime()
public void setDefaultExpiryTime(long defaultExpiryTime)
defaultExpiryTime
- - default expiry time for cached items. When
retrieving an item, if its age exceeds expiry time, then it will be
discarded. Default expiry time is FIFTEEN_MINUTES.public void store(String url, String data)
store(String url, URLData data)
public void store(String url, URLData data)
url
- - URL to be stored in the cache.data
- - data to be stored in the cachepublic void store(String url, String data, long expiry)
store(String url, URLData data, long expiry)
public void store(String url, URLData data, long expiry)
url
- - URL to be stored in the cache.data
- - data to be stored in the cacheexpiry
- - expiry time in milliseconds.public void purge(String url)
public void purgeAll()
public void purgeExpired()
public String retrieve(String url)
retrieveData(String url)
public URLData retrieveData(String url)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |