From a78b5b7b2ac6eff4462548ed523f2e01076e77f3 Mon Sep 17 00:00:00 2001
From: 捏造的信仰 <yiding.he@gmail.com>
Date: Tue, 23 Aug 2022 13:36:29 +0800
Subject: [PATCH] 修复执行任务时,若方法入口在任务的父类,则无法执行的问题 实际项目开发中,可能会为所有定时任务类建一个共同的父类,任务的执行入口在父类定义,以便管理。此时使用 `getDeclaredMethod()` 是无法从子类找到要执行的方法的,而是要换用 `getMethod()` 方法。
---
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java | 50 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
index 3246b77..d0a6de4 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
@@ -75,6 +75,28 @@
}
/**
+ * 获取有效时间
+ *
+ * @param key Redis键
+ * @return 有效时间
+ */
+ public long getExpire(final String key)
+ {
+ return redisTemplate.getExpire(key);
+ }
+
+ /**
+ * 判断 key是否存在
+ *
+ * @param key 键
+ * @return true 存在 false不存在
+ */
+ public Boolean hasKey(String key)
+ {
+ return redisTemplate.hasKey(key);
+ }
+
+ /**
* 获得缓存的基本对象。
*
* @param key 缓存键值
@@ -102,9 +124,9 @@
* @param collection 多个对象
* @return
*/
- public long deleteObject(final Collection collection)
+ public boolean deleteObject(final Collection collection)
{
- return redisTemplate.delete(collection);
+ return redisTemplate.delete(collection) > 0;
}
/**
@@ -210,18 +232,6 @@
}
/**
- * 删除Hash中的数据
- *
- * @param key
- * @param mapkey
- */
- public void delCacheMapValue(final String key, final String hkey)
- {
- HashOperations hashOperations = redisTemplate.opsForHash();
- hashOperations.delete(key, hkey);
- }
-
- /**
* 获取多个Hash中的数据
*
* @param key Redis键
@@ -234,6 +244,18 @@
}
/**
+ * 删除Hash中的某条数据
+ *
+ * @param key Redis键
+ * @param hKey Hash键
+ * @return 是否成功
+ */
+ public boolean deleteCacheMapValue(final String key, final String hKey)
+ {
+ return redisTemplate.opsForHash().delete(key, hKey) > 0;
+ }
+
+ /**
* 获得缓存的基本对象列表
*
* @param pattern 字符串前缀
--
Gitblit v1.9.2