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 java.sql.Connection |
conn |
protected static java.lang.String |
TABLE_NAME |
Constructor and Description |
---|
DatabaseCache(java.sql.Connection connection) |
Modifier and Type | Method and Description |
---|---|
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.
|
createCacheEntryName, getExpirationPolicy, setExpirationPolicy, setHashCacheEntryNames
protected static final java.lang.String TABLE_NAME
protected java.sql.Connection conn
public DatabaseCache(java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLException
protected void createTable() throws java.sql.SQLException
java.sql.SQLException
public boolean contains(java.lang.String cacheEntryName)
Cache
public java.io.InputStream load(java.lang.String cacheEntryName)
Cache
null
if the cache does not contain the specified cacheEntryName.public void remove(java.lang.String cacheEntryName)
Cache
public void store(java.lang.String cacheEntryName, java.io.InputStream inputStream, long expirationDate)
Cache
public boolean isExpired(java.lang.String cacheEntryName)
Cache