commit 3e1fc7dc80909e23a2856740517127938681e923
Author: Lemon <1161030327@qq.com>
Date: Sat Aug 12 10:00:57 2023 +0800
common-redis
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..09bdfea
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,46 @@
+######################################################################
+# Build Tools
+
+.gradle
+/build/
+!gradle/wrapper/gradle-wrapper.jar
+
+target/
+!.mvn/wrapper/maven-wrapper.jar
+
+######################################################################
+# IDE
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### JRebel ###
+rebel.xml
+### NetBeans ###
+nbproject/private/
+build/*
+nbbuild/
+dist/
+nbdist/
+.nb-gradle/
+
+######################################################################
+# Others
+*.log
+*.xml.versionsBackup
+*.swp
+
+!*/build/*.java
+!*/build/*.html
+!*/build/*.xml
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..1c87955
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,41 @@
+
+
+
+ com.luck
+ luck-common
+ 3.6.3
+
+ 4.0.0
+
+ 3.6.3
+ luck-common-redis
+
+
+ luck-common-redis缓存服务
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+
+ com.luck
+ luck-common-core
+
+
+
+
+
+ yun-releases
+ yun-releases
+ http://192.10.29.103/repository/maven-releases/
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/luck/common/redis/configure/FastJson2JsonRedisSerializer.java b/src/main/java/com/luck/common/redis/configure/FastJson2JsonRedisSerializer.java
new file mode 100644
index 0000000..f2680da
--- /dev/null
+++ b/src/main/java/com/luck/common/redis/configure/FastJson2JsonRedisSerializer.java
@@ -0,0 +1,50 @@
+package com.luck.common.redis.configure;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONReader;
+import com.alibaba.fastjson2.JSONWriter;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+
+import java.nio.charset.Charset;
+
+/**
+ * Redis使用FastJson序列化
+ *
+ * @author ruoyi
+ */
+public class FastJson2JsonRedisSerializer implements RedisSerializer
+{
+ public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+
+ private Class clazz;
+
+
+ public FastJson2JsonRedisSerializer(Class clazz)
+ {
+ super();
+ this.clazz = clazz;
+ }
+
+ @Override
+ public byte[] serialize(T t) throws SerializationException
+ {
+ if (t == null)
+ {
+ return new byte[0];
+ }
+ return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
+ }
+
+ @Override
+ public T deserialize(byte[] bytes) throws SerializationException
+ {
+ if (bytes == null || bytes.length <= 0)
+ {
+ return null;
+ }
+ String str = new String(bytes, DEFAULT_CHARSET);
+
+ return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
+ }
+}
diff --git a/src/main/java/com/luck/common/redis/configure/RedisConfig.java b/src/main/java/com/luck/common/redis/configure/RedisConfig.java
new file mode 100644
index 0000000..7bd61fb
--- /dev/null
+++ b/src/main/java/com/luck/common/redis/configure/RedisConfig.java
@@ -0,0 +1,43 @@
+package com.luck.common.redis.configure;
+
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * redis配置
+ *
+ * @author ruoyi
+ */
+@Configuration
+@EnableCaching
+@AutoConfigureBefore(RedisAutoConfiguration.class)
+public class RedisConfig extends CachingConfigurerSupport
+{
+ @Bean
+ @SuppressWarnings(value = { "unchecked", "rawtypes" })
+ public RedisTemplate