use of com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer in project agileway by fangjinuo.
the class StringValueController method createRedisTemplate.
private RedisTemplate createRedisTemplate(TestScope scope) {
RedisTemplate<String, ?> RedisTemplate = null;
switch(scope) {
case JACKSON_COMMON:
RedisTemplate = RedisTemplates.createRedisTemplate(connectionFactory, keyPrefix, new GenericJackson2JsonRedisSerializer(), StringValueController.class.getClassLoader(), RedisTemplates.stringRedisSerializer, null, null, repository, false, true);
break;
case EASYJSON_COMMON:
EasyjsonCodec jsonSerializer = new EasyjsonCodec();
DelegatableRedisSerializer valueSerializer = new DelegatableRedisSerializer(jsonSerializer);
RedisTemplate = RedisTemplates.createRedisTemplate(connectionFactory, keyPrefix, valueSerializer, StringValueController.class.getClassLoader(), RedisTemplates.stringRedisSerializer, null, valueSerializer, repository, false, true);
break;
default:
RedisTemplate = RedisTemplates.createRedisTemplate(connectionFactory, keyPrefix, new StringRedisSerializer(), StringValueController.class.getClassLoader(), RedisTemplates.stringRedisSerializer, null, null, repository, false, true);
break;
}
return RedisTemplate;
}
use of com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer in project agileway by fangjinuo.
the class RedisTemplates method createRedisTemplate.
public static RedisTemplate<String, ?> createRedisTemplate(@NonNull RedisConnectionFactory connectionFactory, RedisTemplateProperties redisTemplateProperties, @Nullable ClassLoader beanClassLoader, @Nullable RedisLuaScriptRepository redisLuaScriptRepository, boolean initIt) {
RedisKeyWrapper keyWrapper = new RedisKeyWrapper(redisTemplateProperties.getKey());
RedisSerializer<String> keySerializer = new RedisKeySerializer(keyWrapper);
Codec<?> codec = newCodec(redisTemplateProperties.getValueCodecType());
RedisSerializer<?> valueSerializer = new DelegatableRedisSerializer(codec);
RedisSerializer hashKeySerializer = new RedisKeySerializer();
return createRedisTemplate(connectionFactory, keySerializer, valueSerializer, beanClassLoader, stringRedisSerializer, hashKeySerializer, valueSerializer, redisLuaScriptRepository, redisTemplateProperties.isTransactionEnabled(), initIt);
}
use of com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer in project agileway by fangjinuo.
the class RedisTemplates method createBeanJsonRedisTemplate.
public static RedisTemplate<String, ?> createBeanJsonRedisTemplate(@NonNull RedisConnectionFactory connectionFactory, @Nullable String keyPrefix, @NonNull Class beanClass, @Nullable RedisSerializer hashKeySerializer, @Nullable RedisSerializer hashValueSerializer, @Nullable RedisLuaScriptRepository redisLuaScriptRepository, boolean enableTx, boolean initIt) {
Preconditions.checkNotNull(beanClass, "the target class is null");
EasyjsonCodec easyjsonRedisSerializer = new EasyjsonCodec();
easyjsonRedisSerializer.setJsonFactory(JsonFactorys.getJSONFactory(JsonScope.SINGLETON));
easyjsonRedisSerializer.setTargetType(beanClass);
return createRedisTemplate(connectionFactory, keyPrefix, new DelegatableRedisSerializer(easyjsonRedisSerializer), beanClass.getClassLoader(), null, hashKeySerializer, hashValueSerializer, redisLuaScriptRepository, enableTx, initIt);
}
use of com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer in project agileway by fangjinuo.
the class RedisTemplates method createEasyjsonCommonJsonRedisTemplate.
public static RedisTemplate<String, ?> createEasyjsonCommonJsonRedisTemplate(@NonNull RedisConnectionFactory connectionFactory, @Nullable String keyPrefix, @NonNull JSONFactory jsonFactory, @Nullable ClassLoader beanClassLoader, @Nullable RedisSerializer<?> hashKeySerializer, @Nullable RedisSerializer<?> hashValueSerializer, @Nullable RedisLuaScriptRepository redisLuaScriptRepository, boolean enableTx, boolean initIt) {
EasyjsonCodec easyjsonRedisSerializer = new EasyjsonCodec();
easyjsonRedisSerializer.setJsonFactory(jsonFactory);
return createRedisTemplate(connectionFactory, keyPrefix, new DelegatableRedisSerializer(easyjsonRedisSerializer), beanClassLoader, null, hashKeySerializer, hashValueSerializer, redisLuaScriptRepository, enableTx, initIt);
}
Aggregations