|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.roarsoftware.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(java.lang.String cacheEntryName)
Checks if the cache contains an entry with the given name. |
static java.lang.String |
createCacheEntryName(java.lang.String method,
java.util.Map<java.lang.String,java.lang.String> params)
Creates a unique entry name string for a request. |
ExpirationPolicy |
getExpirationPolicy()
Returns the active ExpirationPolicy |
abstract boolean |
isExpired(java.lang.String cacheEntryName)
Checks if the specified entry is expired. |
abstract java.io.InputStream |
load(java.lang.String cacheEntryName)
Loads the specified entry from the cache and returns an InputStream to be read from. |
abstract void |
remove(java.lang.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(java.lang.String cacheEntryName,
java.io.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 null
public abstract boolean contains(java.lang.String cacheEntryName)
cacheEntryName
- An entry name
true
if the cache contains this entrypublic abstract java.io.InputStream load(java.lang.String cacheEntryName)
null
if the cache does not contain the specified cacheEntryName.
cacheEntryName
- An entry name
null
public abstract void remove(java.lang.String cacheEntryName)
cacheEntryName
- An entry namepublic abstract void store(java.lang.String cacheEntryName, java.io.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(java.lang.String cacheEntryName)
cacheEntryName
- An entry name
true
if the entry is expiredpublic abstract void clear()
public static java.lang.String createCacheEntryName(java.lang.String method, java.util.Map<java.lang.String,java.lang.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 |