/** */ public CacheJdbcPojoStoreFactory getStoreFactory() { CacheJdbcPojoStoreFactory storeFactory = new CacheJdbcPojoStoreFactory(); storeFactory.setParallelLoadCacheMinimumThreshold(100); storeFactory.setBatchSize(100); storeFactory.setMaximumPoolSize(4); storeFactory.setDataSourceFactory(getDataSourceFactory()); storeFactory.setDialect(new H2Dialect()); storeFactory.setTypes(getJdbcType()); return storeFactory; }
/** * @param factory Store factory to extract JDBC types info. * @return Data transfer object for cache type metadata configurations. */ public static List<VisorCacheJdbcType> list(Factory factory) { List<VisorCacheJdbcType> res = new ArrayList<>(); if (factory instanceof CacheJdbcPojoStoreFactory) { CacheJdbcPojoStoreFactory jdbcFactory = (CacheJdbcPojoStoreFactory) factory; JdbcType[] jdbcTypes = jdbcFactory.getTypes(); if (!F.isEmpty(jdbcTypes)) { for (JdbcType jdbcType : jdbcTypes) res.add(new VisorCacheJdbcType(jdbcType)); } } return res; }
/** * @return Cache configuration for test. * @throws Exception In case when failed to create cache configuration. */ protected CacheConfiguration cacheConfiguration() throws Exception { CacheConfiguration cc = defaultCacheConfiguration(); cc.setName(CACHE_NAME); cc.setCacheMode(PARTITIONED); cc.setAtomicityMode(transactional ? TRANSACTIONAL : ATOMIC); cc.setWriteBehindEnabled(false); cc.setStoreKeepBinary(storeKeepBinary()); CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>(); storeFactory.setDialect(new H2Dialect()); storeFactory.setTypes(storeTypes()); storeFactory.setDataSourceFactory(new H2DataSourceFactory()); // H2 DataSource factory. storeFactory.setSqlEscapeAll(sqlEscapeAll()); storeFactory.setParallelLoadCacheMinimumThreshold(parallelLoadThreshold); cc.setCacheStoreFactory(storeFactory); cc.setReadThrough(true); cc.setWriteThrough(true); cc.setLoadPreviousValue(true); return cc; }
CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>(); storeTypes[6].setValueFields(new JdbcTypeField(Types.BINARY, "VAL", byte[].class, "bytes")); storeFactory.setTypes(storeTypes); storeFactory.setDialect(new H2Dialect()); CacheJdbcPojoStore<Object, Object> store = storeFactory.create();
/** * @param factory Store factory to extract JDBC types info. * @return Data transfer object for cache type metadata configurations. */ public static List<VisorCacheJdbcType> list(Factory factory) { List<VisorCacheJdbcType> res = new ArrayList<>(); if (factory instanceof CacheJdbcPojoStoreFactory) { CacheJdbcPojoStoreFactory jdbcFactory = (CacheJdbcPojoStoreFactory) factory; JdbcType[] jdbcTypes = jdbcFactory.getTypes(); if (!F.isEmpty(jdbcTypes)) { for (JdbcType jdbcType : jdbcTypes) res.add(new VisorCacheJdbcType(jdbcType)); } } return res; }