com.ideaaedi.extspringcache.provider.CommonRedisProvider Maven / Gradle / Ivy
The newest version!
package com.ideaaedi.extspringcache.provider;
import com.ideaaedi.extspringcache.custom.ExtRedisCacheManagerCustomizer;
import com.ideaaedi.extspringcache.custom.ExtRedisSerializerCustomizer;
import com.ideaaedi.extspringcache.properties.ExtSpringCacheProperties;
import com.ideaaedi.extspringcache.redis.ExtRedisCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
/**
* provider common逻辑抽取
*
* @author JustryDeng
* @since 2023-05-31 13:30:25
*/
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public class CommonRedisProvider {
@Autowired
private ExtSpringCacheProperties extSpringCacheProperties;
@Autowired(required = false)
private CacheProperties cacheProperties;
@Autowired(required = false)
private ClassLoader classLoader;
@Autowired(required = false)
private ExtRedisSerializerCustomizer extRedisSerializerCustomizer;
@Autowired(required = false)
private ExtRedisCacheManagerCustomizer extRedisCacheManagerCustomizer;
protected ExtRedisCacheManager getExtRedisCacheManager(@SuppressWarnings("rawtypes") RedisTemplate redisTemplate) {
RedisSerializationContext.SerializationPair keySerializer;
RedisSerializationContext.SerializationPair