public class CacheJdbcBlobStore<K,V> extends CacheStoreAdapter<K,V>
CacheStore
implementation backed by JDBC. This implementation
stores objects in underlying database in BLOB
format.
Store will create table ENTRIES
in the database to store data.
Table will have key
and val
fields.
If custom DDL and DML statements are provided, table and field names have to be consistent for all statements and sequence of parameters have to be preserved.
setDataSource(DataSource)
setConnectionUrl(String)
)setUser(String)
)setPassword(String)
)setConnectionUrl(String)
)setLoadQuery(String)
)setUpdateQuery(String)
)setInsertQuery(String)
)setDeleteQuery(String)
)
Use CacheJdbcBlobStoreFactory
factory to pass CacheJdbcBlobStore
to CacheConfiguration
.
Modifier and Type | Field and Description |
---|---|
static String |
DFLT_CONN_URL
Default connection URL (value is jdbc:gg-h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1).
|
static String |
DFLT_CREATE_TBL_QRY
Default create table query
(value is create table if not exists ENTRIES (akey binary primary key, val binary)).
|
static String |
DFLT_DEL_QRY
Default delete entry query (value is delete from ENTRIES where akey=?
|
static String |
DFLT_INSERT_QRY
Default insert entry query (value is insert into ENTRIES (akey, val) values (?
|
static String |
DFLT_LOAD_QRY
Default load entry query (value is select * from ENTRIES where akey=?
|
static String |
DFLT_UPDATE_QRY
Default update entry query (value is select * from ENTRIES where akey=?
|
Constructor and Description |
---|
CacheJdbcBlobStore() |
Modifier and Type | Method and Description |
---|---|
void |
delete(Object key) |
protected <X> X |
fromBytes(byte[] bytes)
Deserialize object from byte array using marshaller.
|
V |
load(K key) |
protected CacheStoreSession |
session() |
void |
sessionEnd(boolean commit)
Default empty implementation for ending transactions.
|
void |
setConnectionUrl(String connUrl)
Sets connection URL.
|
void |
setCreateTableQuery(String createTblQry)
Sets create table query.
|
void |
setDataSource(DataSource dataSrc)
Sets data source.
|
void |
setDeleteQuery(String delQry)
Sets delete entry query.
|
void |
setInitSchema(boolean initSchema)
Flag indicating whether DB schema should be initialized by Ignite (default behaviour) or
was explicitly created by user.
|
void |
setInsertQuery(String insertQry)
Sets insert entry query.
|
void |
setLoadQuery(String loadQry)
Sets load query.
|
void |
setPassword(String passwd)
Sets password for database access.
|
void |
setUpdateQuery(String updateQry)
Sets update entry query.
|
void |
setUser(String user)
Sets user name for database access.
|
protected byte[] |
toBytes(Object obj)
Serialize object to byte array using marshaller.
|
String |
toString() |
void |
write(javax.cache.Cache.Entry<? extends K,? extends V> entry) |
deleteAll, loadAll, loadCache, writeAll
public static final String DFLT_CONN_URL
public static final String DFLT_CREATE_TBL_QRY
public static final String DFLT_LOAD_QRY
public static final String DFLT_UPDATE_QRY
public static final String DFLT_INSERT_QRY
public static final String DFLT_DEL_QRY
public void sessionEnd(boolean commit)
sessionEnd
in interface CacheStore<K,V>
sessionEnd
in class CacheStoreAdapter<K,V>
commit
- True
if transaction should commit, false
for rollback.public void delete(Object key)
public void setInitSchema(boolean initSchema)
initSchema
- True
if DB schema should be initialized by Ignite (default behaviour),
{code @false} if schema was explicitly created by user.public void setConnectionUrl(String connUrl)
connUrl
- Connection URL.public void setCreateTableQuery(String createTblQry)
createTblQry
- Create table query.public void setLoadQuery(String loadQry)
loadQry
- Load querypublic void setUpdateQuery(String updateQry)
updateQry
- Update entry query.public void setInsertQuery(String insertQry)
insertQry
- Insert entry query.public void setDeleteQuery(String delQry)
delQry
- Delete entry query.public void setUser(String user)
user
- User name.public void setPassword(String passwd)
passwd
- Password.public void setDataSource(DataSource dataSrc)
Note that if data source is provided, all connections will be
acquired via this data source. If data source is not provided, a new connection
will be created for each store call (connectionUrl
,
user
and password
parameters will be used).
dataSrc
- Data source.public String toString()
toString
in class CacheStoreAdapter<K,V>
protected byte[] toBytes(Object obj) throws IgniteCheckedException
obj
- Object to convert to byte array.IgniteCheckedException
- If failed to convert.protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException
X
- Result object type.bytes
- Bytes to deserialize.IgniteCheckedException
- If failed.protected CacheStoreSession session()
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024