Package de.umass.lastfm.cache
Class FileSystemCache
java.lang.Object
de.umass.lastfm.cache.Cache
de.umass.lastfm.cache.FileSystemCache
- All Implemented Interfaces:
ScrobbleCache
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.- Author:
- Janni Kovacs
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cacheScrobble
(SubmissionData... submissions) Caches one or moreSubmissionData
.void
cacheScrobble
(Collection<SubmissionData> submissions) Caches a collection ofSubmissionData
.void
clear()
Clears the cache by effectively removing all cached data.void
Clears all cached scrobbles from this cache.boolean
Checks if the cache contains an entry with the given name.boolean
isEmpty()
Checks if the cache contains any scrobbles.boolean
Checks if the specified entry is expired.Loads the specified entry from the cache and returns an InputStream to be read from.void
Removes the specified entry from the cache if available.void
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
-
Constructor Details
-
FileSystemCache
public FileSystemCache() -
FileSystemCache
-
-
Method Details
-
contains
Description copied from class:Cache
Checks if the cache contains an entry with the given name. -
remove
Description copied from class:Cache
Removes the specified entry from the cache if available. Does nothing if no such entry is available. -
isExpired
Description copied from class:Cache
Checks if the specified entry is expired. -
clear
public void clear()Description copied from class:Cache
Clears the cache by effectively removing all cached data. -
load
Description copied from class:Cache
Loads the specified entry from the cache and returns an InputStream to be read from. Returnsnull
if the cache does not contain the specified cacheEntryName. -
store
Description copied from class:Cache
Stores a request in the cache. -
cacheScrobble
Description copied from interface:ScrobbleCache
Caches a collection ofSubmissionData
.- Specified by:
cacheScrobble
in interfaceScrobbleCache
- Parameters:
submissions
- The submissions
-
cacheScrobble
Description copied from interface:ScrobbleCache
Caches one or moreSubmissionData
.- Specified by:
cacheScrobble
in interfaceScrobbleCache
- Parameters:
submissions
- The submissions
-
isEmpty
public boolean isEmpty()Description copied from interface:ScrobbleCache
Checks if the cache contains any scrobbles.- Specified by:
isEmpty
in interfaceScrobbleCache
- Returns:
true
if this cache is empty
-
scrobble
Description copied from interface:ScrobbleCache
Tries to scrobble all cached scrobbles. If it succeeds the cache will be empty afterwards. If this method fails an IOException is thrown and no entries are removed from the cache.- Specified by:
scrobble
in interfaceScrobbleCache
- Parameters:
scrobbler
- AScrobbler
instance- Throws:
IOException
- on I/O errors
-
clearScrobbleCache
public void clearScrobbleCache()Description copied from interface:ScrobbleCache
Clears all cached scrobbles from this cache.- Specified by:
clearScrobbleCache
in interfaceScrobbleCache
-