public class FileSystemCache extends Cache implements ScrobbleCache
Cache implementation which is used by default by the Caller class.
This implementation caches all responses in the file system. In addition to the raw responses it stores a
.meta file which contains the expiration date for the specified request.| Constructor and Description |
|---|
FileSystemCache() |
FileSystemCache(java.io.File cacheDir) |
| Modifier and Type | Method and Description |
|---|---|
void |
cacheScrobble(java.util.Collection<SubmissionData> submissions)
Caches a collection of
SubmissionData. |
void |
cacheScrobble(SubmissionData... submissions)
Caches one or more
SubmissionData. |
void |
clear()
Clears the cache by effectively removing all cached data.
|
void |
clearScrobbleCache()
Clears all cached scrobbles from this cache.
|
boolean |
contains(java.lang.String cacheEntryName)
Checks if the cache contains an entry with the given name.
|
boolean |
isEmpty()
Checks if the cache contains any scrobbles.
|
boolean |
isExpired(java.lang.String cacheEntryName)
Checks if the specified entry is expired.
|
java.io.InputStream |
load(java.lang.String cacheEntryName)
Loads the specified entry from the cache and returns an InputStream to be read from.
|
void |
remove(java.lang.String cacheEntryName)
Removes the specified entry from the cache if available.
|
void |
scrobble(Scrobbler scrobbler)
Tries to scrobble all cached scrobbles.
|
void |
store(java.lang.String cacheEntryName,
java.io.InputStream inputStream,
long expirationDate)
Stores a request in the cache.
|
createCacheEntryName, getExpirationPolicy, setExpirationPolicy, setHashCacheEntryNamespublic FileSystemCache()
public FileSystemCache(java.io.File cacheDir)
public boolean contains(java.lang.String cacheEntryName)
Cachepublic void remove(java.lang.String cacheEntryName)
Cachepublic boolean isExpired(java.lang.String cacheEntryName)
Cachepublic void clear()
Cachepublic java.io.InputStream load(java.lang.String cacheEntryName)
Cachenull
if the cache does not contain the specified cacheEntryName.public void store(java.lang.String cacheEntryName,
java.io.InputStream inputStream,
long expirationDate)
Cachepublic void cacheScrobble(java.util.Collection<SubmissionData> submissions)
ScrobbleCacheSubmissionData.cacheScrobble in interface ScrobbleCachesubmissions - The submissionspublic void cacheScrobble(SubmissionData... submissions)
ScrobbleCacheSubmissionData.cacheScrobble in interface ScrobbleCachesubmissions - The submissionspublic boolean isEmpty()
ScrobbleCacheisEmpty in interface ScrobbleCachetrue if this cache is emptypublic void scrobble(Scrobbler scrobbler) throws java.io.IOException
ScrobbleCachescrobble in interface ScrobbleCachescrobbler - A Scrobbler instancejava.io.IOException - on I/O errorspublic void clearScrobbleCache()
ScrobbleCacheclearScrobbleCache in interface ScrobbleCache