From 6b2a6ce53898633e17eddc71d0036f969fa9ef71 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Fri, 1 Nov 2024 15:25:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=99=E6=80=81redis=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/redis/StaticRedisCache.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 jsowell-common/src/main/java/com/jsowell/common/core/redis/StaticRedisCache.java diff --git a/jsowell-common/src/main/java/com/jsowell/common/core/redis/StaticRedisCache.java b/jsowell-common/src/main/java/com/jsowell/common/core/redis/StaticRedisCache.java new file mode 100644 index 000000000..8b16a5e92 --- /dev/null +++ b/jsowell-common/src/main/java/com/jsowell/common/core/redis/StaticRedisCache.java @@ -0,0 +1,27 @@ +package com.jsowell.common.core.redis; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +/** + * @Description 静态方法中调用redis + * @Author qizhentao + * @Date 2020/7/1 11:27 + * @Version 1.0 + */ +@Component +public class StaticRedisCache { + + @Autowired + private RedisCache redisCache; + + public static RedisCache staticRedisCache; + + // 项目启动时把redisUtil交给静态的staticRedisUtil + @PostConstruct + public void init() { + staticRedisCache = this.redisCache; + } +}