Search in sources :

Example 1 with RedisKeyWrapper

use of com.jn.agileway.redis.core.key.RedisKeyWrapper 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 2 with RedisKeyWrapper

use of com.jn.agileway.redis.core.key.RedisKeyWrapper in project agileway by fangjinuo.

the class ShiroRedisCacheManager method createCache.

@Override
protected Cache createCache(String cacheName) throws CacheException {
    RedisKeyWrapper redisCacheKeyWrapper = new RedisKeyWrapper().prefix("shiro_redis:" + cacheName);
    RedisCacheContext cacheContext = new RedisCacheContext();
    cacheContext.setLoader(loader);
    cacheContext.setRedisTemplate(redisTemplate);
    cacheContext.setKeyWrapper(redisCacheKeyWrapper);
    cacheContext.setRemoveListener(removeListener);
    RedisCache redisCache = new RedisCacheFactory().get(cacheContext);
    ShiroRedisCache shiroRedisCache = new ShiroRedisCache();
    shiroRedisCache.setRedisCache(redisCache);
    shiroRedisCache.setKeyCodec(keyCodec);
    return shiroRedisCache;
}
Also used : RedisCacheFactory(com.jn.agileway.redis.l2cache.RedisCacheFactory) RedisCache(com.jn.agileway.redis.l2cache.RedisCache) RedisCacheContext(com.jn.agileway.redis.l2cache.RedisCacheContext) RedisKeyWrapper(com.jn.agileway.redis.core.key.RedisKeyWrapper)

Aggregations

RedisKeyWrapper (com.jn.agileway.redis.core.key.RedisKeyWrapper)2 DelegatableRedisSerializer (com.jn.agileway.redis.core.serialization.DelegatableRedisSerializer)1 RedisKeySerializer (com.jn.agileway.redis.core.serialization.RedisKeySerializer)1 RedisCache (com.jn.agileway.redis.l2cache.RedisCache)1 RedisCacheContext (com.jn.agileway.redis.l2cache.RedisCacheContext)1 RedisCacheFactory (com.jn.agileway.redis.l2cache.RedisCacheFactory)1 GenericJackson2JsonRedisSerializer (org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer)1 RedisSerializer (org.springframework.data.redis.serializer.RedisSerializer)1 StringRedisSerializer (org.springframework.data.redis.serializer.StringRedisSerializer)1