|
@@ -16,20 +16,38 @@ object RedisCacheUtil {
|
|
|
return cacheManager.getCache(key)
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取指定类型缓存值
|
|
|
+ */
|
|
|
fun <T : Any> get(cacheKey: String, key: String, type: KClass<T>): T? {
|
|
|
return getCahce(cacheKey)?.get(RedisKeyGenerator.joinToString(cacheKey, key), type.java)
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取ValueWrapper
|
|
|
+ */
|
|
|
fun get(cacheKey: String, key: String): Cache.ValueWrapper? {
|
|
|
return getCahce(cacheKey)?.get(RedisKeyGenerator.joinToString(cacheKey, key))
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 插入(强制)
|
|
|
+ */
|
|
|
fun put(cacheKey: String, key: String, value: Any) {
|
|
|
getCahce(cacheKey)?.put(RedisKeyGenerator.joinToString(cacheKey, key), value)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 插入
|
|
|
+ */
|
|
|
fun putIfAbsent(cacheKey: String, key: String, value: Any) {
|
|
|
getCahce(cacheKey)?.putIfAbsent(RedisKeyGenerator.joinToString(cacheKey, key), value)
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 移除缓存
|
|
|
+ */
|
|
|
+ fun evict(cacheKey: String, key: String) {
|
|
|
+ getCahce(cacheKey)?.evict(key)
|
|
|
+ }
|
|
|
}
|