From dca9c071f77383d3115d6898bea5fb6a0d844aa1 Mon Sep 17 00:00:00 2001
From: lpphan <@163.com>
Date: Fri, 18 Mar 2022 10:25:21 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../redis/template/RedisRepository.java | 993 +++++++++---------
.../oauth/config/RedisListenerConfig.java | 4 +-
.../listener/RedisKeyExpirationListener.java | 9 +-
3 files changed, 505 insertions(+), 501 deletions(-)
diff --git a/zlt-commons/zlt-redis-spring-boot-starter/src/main/java/com/central/common/redis/template/RedisRepository.java b/zlt-commons/zlt-redis-spring-boot-starter/src/main/java/com/central/common/redis/template/RedisRepository.java
index d73cfcac..7c80302f 100644
--- a/zlt-commons/zlt-redis-spring-boot-starter/src/main/java/com/central/common/redis/template/RedisRepository.java
+++ b/zlt-commons/zlt-redis-spring-boot-starter/src/main/java/com/central/common/redis/template/RedisRepository.java
@@ -1,495 +1,498 @@
-package com.central.common.redis.template;
-
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.dao.DataAccessException;
-import org.springframework.data.redis.connection.RedisClusterNode;
-import org.springframework.data.redis.connection.RedisConnection;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.connection.RedisServerCommands;
-import org.springframework.data.redis.core.*;
-import org.springframework.data.redis.serializer.RedisSerializer;
-import org.springframework.data.redis.serializer.SerializationUtils;
-import org.springframework.util.Assert;
-
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Redis Repository
- * redis 基本操作 可扩展,基本够用了
- *
- * @author zlt
- *
- * Blog: https://zlt2000.gitee.io
- * Github: https://github.com/zlt2000
- */
-@Slf4j
-public class RedisRepository {
- /**
- * Spring Redis Template
- */
- private RedisTemplate redisTemplate;
-
- public RedisRepository(RedisTemplate redisTemplate) {
- this.redisTemplate = redisTemplate;
- }
-
- /**
- * 获取链接工厂
- */
- public RedisConnectionFactory getConnectionFactory() {
- return this.redisTemplate.getConnectionFactory();
- }
-
- /**
- * 获取 RedisTemplate对象
- */
- public RedisTemplate getRedisTemplate() {
- return redisTemplate;
- }
-
- /**
- * 清空DB
- *
- * @param node redis 节点
- */
- public void flushDB(RedisClusterNode node) {
- this.redisTemplate.opsForCluster().flushDb(node);
- }
-
- /**
- * 添加到带有 过期时间的 缓存
- *
- * @param key redis主键
- * @param value 值
- * @param time 过期时间(单位秒)
- */
- public void setExpire(final byte[] key, final byte[] value, final long time) {
- redisTemplate.execute((RedisCallback) connection -> {
- connection.setEx(key, time, value);
- return 1L;
- });
- }
-
- /**
- * 添加到带有 过期时间的 缓存
- *
- * @param key redis主键
- * @param value 值
- * @param time 过期时间
- * @param timeUnit 过期时间单位
- */
- public void setExpire(final String key, final Object value, final long time, final TimeUnit timeUnit) {
- redisTemplate.opsForValue().set(key, value, time, timeUnit);
- }
- public void setExpire(final String key, final Object value, final long time) {
- this.setExpire(key, value, time, TimeUnit.SECONDS);
- }
- public void setExpire(final String key, final Object value, final long time, final TimeUnit timeUnit, RedisSerializer