|
|||||||||
| 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.DatabaseCache
public class DatabaseCache
Generic class for caching into a database. It's constructor takes a 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.
| Field Summary | |
|---|---|
protected java.sql.Connection |
conn
|
protected static java.lang.String |
TABLE_NAME
|
| Constructor Summary | |
|---|---|
DatabaseCache(java.sql.Connection connection)
|
|
| Method Summary | |
|---|---|
void |
clear()
Clears the cache by effectively removing all cached data. |
boolean |
contains(java.lang.String cacheEntryName)
Checks if the cache contains an entry with the given name. |
protected void |
createTable()
|
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 |
store(java.lang.String cacheEntryName,
java.io.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 |
| Field Detail |
|---|
protected static final java.lang.String TABLE_NAME
protected java.sql.Connection conn
| Constructor Detail |
|---|
public DatabaseCache(java.sql.Connection connection)
throws java.sql.SQLException
java.sql.SQLException| Method Detail |
|---|
protected void createTable()
throws java.sql.SQLException
java.sql.SQLExceptionpublic boolean contains(java.lang.String cacheEntryName)
Cache
contains in class CachecacheEntryName - An entry name
true if the cache contains this entrypublic java.io.InputStream load(java.lang.String cacheEntryName)
Cachenull
if the cache does not contain the specified cacheEntryName.
load in class CachecacheEntryName - An entry name
nullpublic void remove(java.lang.String cacheEntryName)
Cache
remove in class CachecacheEntryName - An entry name
public void store(java.lang.String cacheEntryName,
java.io.InputStream inputStream,
long expirationDate)
Cache
store in class CachecacheEntryName - 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 boolean isExpired(java.lang.String cacheEntryName)
Cache
isExpired in class CachecacheEntryName - An entry name
true if the entry is expiredpublic void clear()
Cache
clear in class Cache
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||