Package de.umass.lastfm.cache
Class DatabaseCache
java.lang.Object
de.umass.lastfm.cache.Cache
de.umass.lastfm.cache.DatabaseCache
Generic class for caching into a database. It's constructor takes a
For more specialized versions of this class for different databases one may extend this class and override methods as needed.
Connection
instance, which must
be opened and closed by the client. SQL code used in this class should work with all common databases
(which support varchar, timestamp and longvarchar datatypes).For more specialized versions of this class for different databases one may extend this class and override methods as needed.
- Author:
- Janni Kovacs
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the cache by effectively removing all cached data.boolean
Checks if the cache contains an entry with the given name.protected void
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
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
-
Field Details
-
TABLE_NAME
- See Also:
-
conn
-
-
Constructor Details
-
DatabaseCache
- Throws:
SQLException
-
-
Method Details
-
createTable
- Throws:
SQLException
-
contains
Description copied from class:Cache
Checks if the cache contains an entry with the given name. -
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. -
remove
Description copied from class:Cache
Removes the specified entry from the cache if available. Does nothing if no such entry is available. -
store
Description copied from class:Cache
Stores a request in the cache. -
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.
-