|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.umass.lastfm.cache.Cache
de.umass.lastfm.cache.FileSystemCache
public class FileSystemCache
Standard 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 Summary | |
---|---|
FileSystemCache()
|
|
FileSystemCache(File cacheDir)
|
Method Summary | |
---|---|
void |
cacheScrobble(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(String cacheEntryName)
Checks if the cache contains an entry with the given name. |
boolean |
isEmpty()
Checks if the cache contains any scrobbles. |
boolean |
isExpired(String cacheEntryName)
Checks if the specified entry is expired. |
InputStream |
load(String cacheEntryName)
Loads the specified entry from the cache and returns an InputStream to be read from. |
void |
remove(String cacheEntryName)
Removes the specified entry from the cache if available. |
void |
scrobble(Scrobbler scrobbler)
Tries to scrobble all cached scrobbles. |
void |
store(String cacheEntryName,
InputStream inputStream,
long expirationDate)
Stores a request in the cache. |
Methods inherited from class de.umass.lastfm.cache.Cache |
---|
createCacheEntryName, getExpirationPolicy, setExpirationPolicy, setHashCacheEntryNames |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileSystemCache()
public FileSystemCache(File cacheDir)
Method Detail |
---|
public boolean contains(String cacheEntryName)
Cache
contains
in class Cache
cacheEntryName
- An entry name
true
if the cache contains this entrypublic void remove(String cacheEntryName)
Cache
remove
in class Cache
cacheEntryName
- An entry namepublic boolean isExpired(String cacheEntryName)
Cache
isExpired
in class Cache
cacheEntryName
- An entry name
true
if the entry is expiredpublic void clear()
Cache
clear
in class Cache
public InputStream load(String cacheEntryName)
Cache
null
if the cache does not contain the specified cacheEntryName.
load
in class Cache
cacheEntryName
- An entry name
null
public void store(String cacheEntryName, InputStream inputStream, long expirationDate)
Cache
store
in class Cache
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 void cacheScrobble(Collection<SubmissionData> submissions)
ScrobbleCache
SubmissionData
.
cacheScrobble
in interface ScrobbleCache
submissions
- The submissionspublic void cacheScrobble(SubmissionData... submissions)
ScrobbleCache
SubmissionData
.
cacheScrobble
in interface ScrobbleCache
submissions
- The submissionspublic boolean isEmpty()
ScrobbleCache
isEmpty
in interface ScrobbleCache
true
if this cache is emptypublic void scrobble(Scrobbler scrobbler) throws IOException
ScrobbleCache
scrobble
in interface ScrobbleCache
scrobbler
- A Scrobbler
instance
IOException
- on I/O errorspublic void clearScrobbleCache()
ScrobbleCache
clearScrobbleCache
in interface ScrobbleCache
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |