生成收藏模块代码.

This commit is contained in:
lijiahang
2023-09-01 17:17:35 +08:00
parent 72b219cf95
commit a4875154df
19 changed files with 731 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package com.orion.ops.framework.redis.core.utils;
import com.alibaba.fastjson.JSON;
import com.orion.lang.define.cache.CacheKeyDefine;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.io.Streams;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.RedisCallback;
@@ -26,6 +27,19 @@ public class RedisUtils {
private RedisUtils() {
}
/**
* 扫描 key
*
* @param match 匹配值
* @return keys
*/
public static Set<String> scanKeys(String match) {
// TODO TEST
return scanKeys(ScanOptions.scanOptions()
.match(match)
.build());
}
/**
* 扫描 key
*
@@ -92,6 +106,28 @@ public class RedisUtils {
setJson(key, define, cache);
}
/**
* 设置 json
*
* @param key key
* @param define define
* @param value value
*/
public static void set(String key, CacheKeyDefine define, Object value) {
if (value == null) {
value = Strings.EMPTY;
}
if (define.getTimeout() == 0) {
// 不过期
redisTemplate.opsForValue().set(key, value.toString());
} else {
// 过期
redisTemplate.opsForValue().set(key, value.toString(),
define.getTimeout(),
define.getUnit());
}
}
/**
* 设置 json
*