Package org.gridgain.cache.store.jdbc
Class MariaDbCacheStoreFactory
java.lang.Object
org.gridgain.cache.store.jdbc.JdbcCacheStoreFactory
org.gridgain.cache.store.jdbc.MariaDbCacheStoreFactory
- All Implemented Interfaces:
CacheStoreFactory
Factory producing a
MariaDbCacheStore preconfigured with MariaDbDialect. For dialect-agnostic configuration,
JdbcCacheStoreFactory combined with setDialect(new MariaDbDialect()) is the standard alternative.-
Field Summary
Fields inherited from class org.gridgain.cache.store.jdbc.JdbcCacheStoreFactory
DFLT_BATCH_SIZE, DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD, DFLT_WRITE_ATTEMPTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <K,V> JdbcCacheStore<K, V> createStore(Class<K> keyCls, Class<V> valCls) Creates the store instance thatJdbcCacheStoreFactory.create(Class, Class)then configures.intGets the fetch size passed to JDBCStatement.setFetchSizefor load cache queries.setBatchSize(int batchSize) Set maximum batch size for write and delete operations.setDataSource(DataSource dataSrc) Sets data source.setDialect(JdbcDialect dialect) Set database dialect.setExecutor(ExecutorService executor) Sets the executor for accessing the database.setFetchSize(int fetchSize) Sets the fetch size passed to JDBCStatement.setFetchSizefor load cache queries, replacing the installed dialect.setMaximumWriteAttempts(int maxWrtAttempts) Sets maximum number of write attempts in case of database error.setParallelLoadCacheMinimumThreshold(int parallelLoadCacheMinThreshold) Parallel load cache minimum row count threshold.setSqlEscapeAll(boolean sqlEscapeAll) Iftrueall the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName").setTransformer(JdbcTypesTransformer transformer) Sets types transformer.Sets store configurations.toString()Methods inherited from class org.gridgain.cache.store.jdbc.JdbcCacheStoreFactory
create, getBatchSize, getDataSource, getDialect, getExecutor, getMaximumWriteAttempts, getParallelLoadCacheMinimumThreshold, getTransformer, getType, isSqlEscapeAll
-
Constructor Details
-
MariaDbCacheStoreFactory
public MariaDbCacheStoreFactory()Constructor.
-
-
Method Details
-
getFetchSize
public int getFetchSize()Gets the fetch size passed to JDBCStatement.setFetchSizefor load cache queries.- Returns:
- Fetch size.
-
setFetchSize
Sets the fetch size passed to JDBCStatement.setFetchSizefor load cache queries, replacing the installed dialect.- Parameters:
fetchSize- Fetch size.- Returns:
Thisfor chaining.
-
setDataSource
Sets data source. Data source should be fully configured and ready-to-use.- Overrides:
setDataSourcein classJdbcCacheStoreFactory- Parameters:
dataSrc- Data source.- Returns:
Thisfor chaining.
-
createStore
Creates the store instance thatJdbcCacheStoreFactory.create(Class, Class)then configures.- Overrides:
createStorein classJdbcCacheStoreFactory- Type Parameters:
K- Key type.V- Value type.- Parameters:
keyCls- Key class.valCls- Value class.- Returns:
- Unconfigured store.
-
setExecutor
Sets the executor for accessing the database. By defaultForkJoinPool.commonPool()executor is used.Thread safety note: it's possible to run into deadlock issue then using a connection pool if a number of user threads accessing cache store is larger than underlying pool size. To mitigate this issue make sure the executor's pool size is large enough, or use a single-threaded executor. This is the safest option.
- Overrides:
setExecutorin classJdbcCacheStoreFactory- Parameters:
executor- The executor.- Returns:
Thisfor chaining.
-
setBatchSize
Set maximum batch size for write and delete operations.- Overrides:
setBatchSizein classJdbcCacheStoreFactory- Parameters:
batchSize- Maximum batch size.- Returns:
Thisfor chaining.
-
setDialect
Set database dialect.- Overrides:
setDialectin classJdbcCacheStoreFactory- Parameters:
dialect- Database dialect.- Returns:
Thisfor chaining.
-
setMaximumWriteAttempts
Sets maximum number of write attempts in case of database error.- Overrides:
setMaximumWriteAttemptsin classJdbcCacheStoreFactory- Parameters:
maxWrtAttempts- Number of write attempts.- Returns:
Thisfor chaining.
-
setParallelLoadCacheMinimumThreshold
public MariaDbCacheStoreFactory setParallelLoadCacheMinimumThreshold(int parallelLoadCacheMinThreshold) Parallel load cache minimum row count threshold.- Overrides:
setParallelLoadCacheMinimumThresholdin classJdbcCacheStoreFactory- Parameters:
parallelLoadCacheMinThreshold- Minimum row count threshold. If0then load sequentially.- Returns:
Thisfor chaining.
-
setType
Sets store configurations.- Overrides:
setTypein classJdbcCacheStoreFactory- Parameters:
type- Store should process.- Returns:
Thisfor chaining.
-
setTransformer
Sets types transformer.- Overrides:
setTransformerin classJdbcCacheStoreFactory- Parameters:
transformer- Types transformer.- Returns:
Thisfor chaining.
-
setSqlEscapeAll
Iftrueall the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName"). This enforces case sensitivity for field names and also allows having special characters in table and field names.- Overrides:
setSqlEscapeAllin classJdbcCacheStoreFactory- Parameters:
sqlEscapeAll- Flag value.- Returns:
thisfor chaining.
-
toString
- Overrides:
toStringin classJdbcCacheStoreFactory
-