|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.umass.lastfm.cache.Cache
public abstract class Cache
The Cache handles storing and loading to a permanent storage for last.fm api requests. This could be
a file system or a sql database.
Caller.setCache(Cache),
ExpirationPolicy| Constructor Summary | |
|---|---|
protected |
Cache()
|
| Method Summary | |
|---|---|
abstract void |
clear()
Clears the cache by effectively removing all cached data. |
abstract boolean |
contains(String cacheEntryName)
Checks if the cache contains an entry with the given name. |
static String |
createCacheEntryName(String method,
Map<String,String> params)
Creates a unique entry name string for a request. |
long |
findExpirationDate(String method,
Map<String,String> params)
Finds the expiration date, returned as a unix timestamp, for a given method/parameters combination, or -1 if there's no expiration time found in this Cache's ExpirationPolicy.It uses this cache's ExpirationPolicy and the current timestamp to calculate the expiration date. |
ExpirationPolicy |
getExpirationPolicy()
Returns the active ExpirationPolicy |
abstract boolean |
isExpired(String cacheEntryName)
Checks if the specified entry is expired. |
abstract InputStream |
load(String cacheEntryName)
Loads the specified entry from the cache and returns an InputStream to be read from. |
abstract void |
remove(String cacheEntryName)
Removes the specified entry from the cache if available. |
void |
setExpirationPolicy(ExpirationPolicy expirationPolicy)
Sets the active ExpirationPolicy. |
static void |
setHashCacheEntryNames(boolean hashCacheEntryNames)
If hashCacheEntryNames is set to true the createCacheEntryName(java.lang.String, java.util.Map method will
return a hash of the original entry name instead of the name itself. |
abstract void |
store(String cacheEntryName,
InputStream inputStream,
long expirationDate)
Stores a request in the cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected Cache()
| Method Detail |
|---|
public ExpirationPolicy getExpirationPolicy()
ExpirationPolicy
public void setExpirationPolicy(ExpirationPolicy expirationPolicy)
ExpirationPolicy.
expirationPolicy - An ExpirationPolicy, not nullpublic abstract boolean contains(String cacheEntryName)
cacheEntryName - An entry name
true if the cache contains this entrypublic abstract InputStream load(String cacheEntryName)
null
if the cache does not contain the specified cacheEntryName.
cacheEntryName - An entry name
nullpublic abstract void remove(String cacheEntryName)
cacheEntryName - An entry name
public abstract void store(String cacheEntryName,
InputStream inputStream,
long expirationDate)
cacheEntryName - The entry name to be stored toinputStream - An InputStream containing the data to be cachedexpirationDate - The date of expiration represented in milliseconds since 1.1.1970public abstract boolean isExpired(String cacheEntryName)
cacheEntryName - An entry name
true if the entry is expiredpublic abstract void clear()
public final long findExpirationDate(String method,
Map<String,String> params)
ExpirationPolicy.ExpirationPolicy and the current timestamp to calculate the expiration date.
method - The method calledparams - The parameters sent
ExpirationPolicy.getExpirationTime(String, java.util.Map)
public static String createCacheEntryName(String method,
Map<String,String> params)
hashCacheEntryNames is set to true this method will return a MD5 hash of
the generated name.
method - The request methodparams - The request parameters
public static void setHashCacheEntryNames(boolean hashCacheEntryNames)
hashCacheEntryNames is set to true the createCacheEntryName(java.lang.String, java.util.Map) method will
return a hash of the original entry name instead of the name itself.
hashCacheEntryNames - true to generate hashes
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||