use of com.lcache.core.model.CacheConfigModel in project lcache by long172066912.
the class assertTest method getExecutor.
@Test
public void getExecutor() {
assertEquals(jedis, CacheClientFactory.getCacheExecutor(new CacheConfigModel().setClientType(RedisClientConstants.JEDIS).setConnectTypeEnum(ConnectTypeEnum.POOL).setCacheType("test"), new JedisConnectSourceConfig()));
assertEquals(lettuce, CacheClientFactory.getCacheExecutor(new CacheConfigModel().setClientType(RedisClientConstants.LETTUCE).setConnectTypeEnum(ConnectTypeEnum.SIMPLE).setCacheType("test1"), new LettuceConnectSourceConfig()));
assertEquals(jedis, CacheClientFactory.builder().cacheType("test").clientType(RedisClientConstants.JEDIS).connectType(ConnectTypeEnum.POOL).cacheConfig(new JedisConnectSourceConfig()).build());
assertEquals(lettuce, CacheClientFactory.builder().cacheType("test1").clientType(RedisClientConstants.LETTUCE).connectType(ConnectTypeEnum.SIMPLE).cacheConfig(new LettuceConnectSourceConfig()).build());
}
use of com.lcache.core.model.CacheConfigModel in project lcache by long172066912.
the class CacheConfigUtils method checkIsEquals.
/**
* 检测2个key是否相等,cacheType+clientType+connectType
*
* @param hashKey1
* @param hashKey2
* @return
*/
public static boolean checkIsEquals(String hashKey1, String hashKey2) {
CacheConfigModel cacheConfigModel1 = hashKeyToModel(hashKey1);
CacheConfigModel cacheConfigModel2 = hashKeyToModel(hashKey2);
return cacheConfigModel1.getCacheType().equals(cacheConfigModel2.getCacheType()) && cacheConfigModel1.getClientType() == cacheConfigModel2.getClientType() && cacheConfigModel1.getConnectTypeEnum().equals(cacheConfigModel2.getConnectTypeEnum()) && cacheConfigModel1.getConfigSourceType().equals(cacheConfigModel2.getConfigSourceType());
}
use of com.lcache.core.model.CacheConfigModel in project lcache by long172066912.
the class CacheClientFactory method getCacheExecutor.
/**
* 自定义配置获取缓存执行器
*
* @param cacheType
* @param config
* @return
*/
public static BaseCacheExecutor getCacheExecutor(String cacheType, BaseCacheConfig config) {
CacheConfigModel cacheConfigModel = new CacheConfigModel();
cacheConfigModel.setConfigSourceType(CacheConfigSourceTypeEnum.CUSTOM);
cacheConfigModel.setCacheType(cacheType);
return CacheExecutorFactory.getCacheExecutor(config, cacheConfigModel);
}
use of com.lcache.core.model.CacheConfigModel in project lcache by long172066912.
the class AbstractLettuceHandleExecutor method pSync.
/**
* Lettuce管道需要使用新的连接
*
* @param commands
* @return
*/
@Override
public List<Object> pSync(List<PipelineCmd> commands) {
// 设置使用方式为管道
CacheConfigModel pipelineCacheConfigModel = new CacheConfigModel(this.getCacheConfigModel(), UseTypeEnum.PIPELINE);
// 获取管道专用链接
StatefulConnection statefulConnection = this.getStatefulConnection(new ConnectResource().setConnectResource(this.getPipelineConnectResource(pipelineCacheConfigModel)));
try {
List<Object> res = new ArrayList<>();
List<RedisFuture<?>> redisFutures = new LettucePipelineExecutor(this.async(statefulConnection)).pSync(commands);
for (int i = 0; i < redisFutures.size(); i++) {
try {
res.add(redisFutures.get(i).get());
} catch (Exception e) {
CacheExceptionFactory.addErrorLog("AbstractLettuceHandleExecutor->pSync get error ! size:" + i, e);
}
}
return res;
} finally {
// 关闭连接
// connectionResource.close();
}
}
Aggregations