Class JdbcCacheStoreFactory

java.lang.Object
org.gridgain.cache.store.jdbc.JdbcCacheStoreFactory
All Implemented Interfaces:
CacheStoreFactory

public class JdbcCacheStoreFactory extends Object implements CacheStoreFactory
JDBC cache store factory.
  • Field Details

    • DFLT_WRITE_ATTEMPTS

      public static final int DFLT_WRITE_ATTEMPTS
      Default value for write attempts.
      See Also:
    • DFLT_BATCH_SIZE

      public static final int DFLT_BATCH_SIZE
      Default batch size for put and remove operations.
      See Also:
    • DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD

      public static final int DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD
      Default batch size for put and remove operations.
      See Also:
  • Constructor Details

    • JdbcCacheStoreFactory

      public JdbcCacheStoreFactory()
  • Method Details

    • create

      public <K, V> CacheStore<K,V> create(Class<K> keyCls, Class<V> valCls)
      Description copied from interface: CacheStoreFactory
      Create a cache store suitable to work with given key and value types.
      Specified by:
      create in interface CacheStoreFactory
      Type Parameters:
      K - Key type.
      V - Value type.
      Parameters:
      keyCls - Key class.
      valCls - Value class.
      Returns:
      The cache store instance.
    • getExecutor

      public ExecutorService getExecutor()
      Get executor.
      Returns:
      The executor.
    • setExecutor

      public JdbcCacheStoreFactory setExecutor(ExecutorService executor)
      Sets the executor for accessing the database. By default ForkJoinPool.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.

      Parameters:
      executor - The executor.
      Returns:
      This for chaining.
    • getDataSource

      public DataSource getDataSource()
      Get data source.
      Returns:
      Data source.
    • setDataSource

      public JdbcCacheStoreFactory setDataSource(DataSource dataSrc)
      Sets data source. Data source should be fully configured and ready-to-use.
      Parameters:
      dataSrc - Data source.
      Returns:
      This for chaining.
    • getBatchSize

      public int getBatchSize()
      Get maximum batch size for delete and delete operations.
      Returns:
      Maximum batch size.
    • setBatchSize

      public JdbcCacheStoreFactory setBatchSize(int batchSize)
      Set maximum batch size for write and delete operations.
      Parameters:
      batchSize - Maximum batch size.
      Returns:
      This for chaining.
    • getDialect

      public JdbcDialect getDialect()
      Get database dialect.
      Returns:
      Database dialect.
    • setDialect

      public JdbcCacheStoreFactory setDialect(JdbcDialect dialect)
      Set database dialect.
      Parameters:
      dialect - Database dialect.
      Returns:
      This for chaining.
    • getMaximumWriteAttempts

      public int getMaximumWriteAttempts()
      Gets maximum number of write attempts in case of database error.
      Returns:
      Maximum number of write attempts.
    • setMaximumWriteAttempts

      public JdbcCacheStoreFactory setMaximumWriteAttempts(int maxWrtAttempts)
      Sets maximum number of write attempts in case of database error.
      Parameters:
      maxWrtAttempts - Number of write attempts.
      Returns:
      This for chaining.
    • getParallelLoadCacheMinimumThreshold

      public int getParallelLoadCacheMinimumThreshold()
      Parallel load cache minimum row count threshold.
      Returns:
      If 0 then load sequentially.
    • setParallelLoadCacheMinimumThreshold

      public JdbcCacheStoreFactory setParallelLoadCacheMinimumThreshold(int parallelLoadCacheMinThreshold)
      Parallel load cache minimum row count threshold.
      Parameters:
      parallelLoadCacheMinThreshold - Minimum row count threshold. If 0 then load sequentially.
      Returns:
      This for chaining.
    • getType

      public JdbcType getType()
      Gets types known by store.
      Returns:
      Types known by store.
    • setType

      public JdbcCacheStoreFactory setType(JdbcType type)
      Sets store configurations.
      Parameters:
      type - Store should process.
      Returns:
      This for chaining.
    • getTransformer

      public JdbcTypesTransformer getTransformer()
      Gets types transformer.
      Returns:
      Types transformer.
    • setTransformer

      public JdbcCacheStoreFactory setTransformer(JdbcTypesTransformer transformer)
      Sets types transformer.
      Parameters:
      transformer - Types transformer.
      Returns:
      This for chaining.
    • isSqlEscapeAll

      public boolean isSqlEscapeAll()
      If true all 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.
      Returns:
      Flag value.
    • setSqlEscapeAll

      public JdbcCacheStoreFactory setSqlEscapeAll(boolean sqlEscapeAll)
      If true all 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.
      Parameters:
      sqlEscapeAll - Flag value.
      Returns:
      this for chaining.
    • toString

      public String toString()
      Overrides:
      toString in class Object