Search in sources :

Example 1 with DelegatableRedisSerializer

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;
}
Also used : EasyjsonCodec(com.jn.agileway.codec.serialization.json.EasyjsonCodec) StringRedisSerializer(org.springframework.data.redis.serializer.StringRedisSerializer) GenericJackson2JsonRedisSerializer(org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer) DelegatableRedisSerializer(com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)

Example 2 with DelegatableRedisSerializer

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);
}
Also used : DelegatableRedisSerializer(com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer) GenericJackson2JsonRedisSerializer(org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer) StringRedisSerializer(org.springframework.data.redis.serializer.StringRedisSerializer) RedisSerializer(org.springframework.data.redis.serializer.RedisSerializer) DelegatableRedisSerializer(com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer) RedisKeyWrapper(com.jn.agileway.redis.core.key.RedisKeyWrapper) RedisKeySerializer(com.jn.agileway.redis.core.serialization.RedisKeySerializer)

Example 3 with DelegatableRedisSerializer

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);
}
Also used : EasyjsonCodec(com.jn.agileway.codec.serialization.json.EasyjsonCodec) DelegatableRedisSerializer(com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)

Example 4 with DelegatableRedisSerializer

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);
}
Also used : EasyjsonCodec(com.jn.agileway.codec.serialization.json.EasyjsonCodec) DelegatableRedisSerializer(com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)

Aggregations

DelegatableRedisSerializer (com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)4 EasyjsonCodec (com.jn.agileway.codec.serialization.json.EasyjsonCodec)3 GenericJackson2JsonRedisSerializer (org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer)2 StringRedisSerializer (org.springframework.data.redis.serializer.StringRedisSerializer)2 RedisKeyWrapper (com.jn.agileway.redis.core.key.RedisKeyWrapper)1 RedisKeySerializer (com.jn.agileway.redis.core.serialization.RedisKeySerializer)1 RedisSerializer (org.springframework.data.redis.serializer.RedisSerializer)1