public class JDBCCacheLoader extends AbstractJDBCLoaderWriter implements net.sf.ehcache.loader.CacheLoader
CacheLoader
that loads data from a database table. Assumes
that toString() method on the keys used in this cache provides a good database identifier.
Can be used in conjunction it with JDBCCacheWriter
to implement a write-through
or write-behind caching use-case.Constructor and Description |
---|
JDBCCacheLoader(DataSource source,
String tableName)
Create an instance
|
Modifier and Type | Method and Description |
---|---|
net.sf.ehcache.loader.CacheLoader |
clone(net.sf.ehcache.Ehcache cache) |
void |
dispose() |
String |
getName() |
net.sf.ehcache.Status |
getStatus() |
void |
init() |
Object |
load(Object key) |
Object |
load(Object key,
Object argument) |
Map |
loadAll(Collection keys) |
Map |
loadAll(Collection keys,
Object argument) |
get, getTableName, put, remove
public JDBCCacheLoader(DataSource source, String tableName)
source
- the data sourcetableName
- the name of the table to load fromIllegalStateException
- if the table is not already configured in the databasepublic net.sf.ehcache.loader.CacheLoader clone(net.sf.ehcache.Ehcache cache) throws CloneNotSupportedException
clone
in interface net.sf.ehcache.loader.CacheLoader
CloneNotSupportedException
public void dispose() throws net.sf.ehcache.CacheException
dispose
in interface net.sf.ehcache.loader.CacheLoader
net.sf.ehcache.CacheException
public String getName()
getName
in interface net.sf.ehcache.loader.CacheLoader
public net.sf.ehcache.Status getStatus()
getStatus
in interface net.sf.ehcache.loader.CacheLoader
public void init()
init
in interface net.sf.ehcache.loader.CacheLoader
@Nullable public Object load(Object key) throws net.sf.ehcache.CacheException
load
in interface net.sf.ehcache.loader.CacheLoader
net.sf.ehcache.CacheException
@Nullable public Object load(Object key, Object argument)
load
in interface net.sf.ehcache.loader.CacheLoader
public Map loadAll(Collection keys)
loadAll
in interface net.sf.ehcache.loader.CacheLoader
public Map loadAll(Collection keys, Object argument)
loadAll
in interface net.sf.ehcache.loader.CacheLoader