de.umass.lastfm.cache
public class DatabaseCache extends Cache
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).Modifier and Type | Field and Description |
---|---|
protected Connection |
conn |
protected static String |
TABLE_NAME |
Constructor and Description |
---|
DatabaseCache(Connection connection) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the cache by effectively removing all cached data.
|
boolean |
contains(String cacheEntryName)
Checks if the cache contains an entry with the given name.
|
protected void |
createTable() |
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 |
store(String cacheEntryName,
InputStream inputStream,
long expirationDate)
Stores a request in the cache.
|
createCacheEntryName, getExpirationPolicy, setExpirationPolicy, setHashCacheEntryNames
protected static final String TABLE_NAME
protected Connection conn
public DatabaseCache(Connection connection) throws SQLException
SQLException
protected void createTable() throws SQLException
SQLException
public boolean contains(String cacheEntryName)
Cache
public InputStream load(String cacheEntryName)
Cache
null
if the cache does not contain the specified cacheEntryName.public void remove(String cacheEntryName)
Cache
public void store(String cacheEntryName, InputStream inputStream, long expirationDate)
Cache
public boolean isExpired(String cacheEntryName)
Cache