parent
8b704ff483
commit
0b17298963
@ -1,27 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.tenant.core.redis;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine;
|
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
class TenantRedisKeyDefineTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFormatKey() {
|
|
||||||
Long tenantId = 30L;
|
|
||||||
TenantContextHolder.setTenantId(tenantId);
|
|
||||||
// 准备参数
|
|
||||||
TenantRedisKeyDefine define = new TenantRedisKeyDefine("", "user:%d:%d", RedisKeyDefine.KeyTypeEnum.HASH,
|
|
||||||
Object.class, RedisKeyDefine.TimeoutTypeEnum.FIXED);
|
|
||||||
Long userId = 10L;
|
|
||||||
Integer userType = 1;
|
|
||||||
|
|
||||||
// 调用
|
|
||||||
String key = define.formatKey(userId, userType);
|
|
||||||
// 断言
|
|
||||||
assertEquals("user:10:1:30", key);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.redis.core;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link RedisKeyDefine} 注册表
|
|
||||||
*/
|
|
||||||
public class RedisKeyRegistry {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redis RedisKeyDefine 数组
|
|
||||||
*/
|
|
||||||
private static final List<RedisKeyDefine> DEFINES = new ArrayList<>();
|
|
||||||
|
|
||||||
public static void add(RedisKeyDefine define) {
|
|
||||||
DEFINES.add(define);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<RedisKeyDefine> list() {
|
|
||||||
return DEFINES;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int size() {
|
|
||||||
return DEFINES.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.infra.controller.admin.redis.vo;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - Redis Key 信息 Response VO")
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class RedisKeyDefineRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "Key 模板", requiredMode = Schema.RequiredMode.REQUIRED, example = "login_user:%s")
|
|
||||||
private String keyTemplate;
|
|
||||||
|
|
||||||
@Schema(description = "Key 类型的枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "String")
|
|
||||||
private RedisKeyDefine.KeyTypeEnum keyType;
|
|
||||||
|
|
||||||
@Schema(description = "Value 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "java.lang.String")
|
|
||||||
private Class<?> valueType;
|
|
||||||
|
|
||||||
@Schema(description = "超时类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
private RedisKeyDefine.TimeoutTypeEnum timeoutType;
|
|
||||||
|
|
||||||
@Schema(description = "过期时间,单位:毫秒", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Duration timeout;
|
|
||||||
|
|
||||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "啦啦啦啦~")
|
|
||||||
private String memo;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.infra.controller.admin.redis.vo;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - Redis Key 信息 Response VO")
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class RedisKeyRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "login_user:%s", requiredMode = Schema.RequiredMode.REQUIRED, example = "String")
|
|
||||||
private String keyTemplate;
|
|
||||||
|
|
||||||
@Schema(description = "Key 类型的枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "String")
|
|
||||||
private RedisKeyDefine.KeyTypeEnum keyType;
|
|
||||||
|
|
||||||
@Schema(description = "Value 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "java.lang.String")
|
|
||||||
private Class<?> valueType;
|
|
||||||
|
|
||||||
@Schema(description = "超时类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
private RedisKeyDefine.TimeoutTypeEnum timeoutType;
|
|
||||||
|
|
||||||
@Schema(description = "过期时间,单位:毫秒", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Duration timeout;
|
|
||||||
|
|
||||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "啦啦啦啦~")
|
|
||||||
private String memo;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.infra.controller.admin.redis.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 单个 Redis Key Value Response VO")
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class RedisKeyValueRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "c5f6990767804a928f4bb96ca249febf", requiredMode = Schema.RequiredMode.REQUIRED, example = "String")
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, example = "String")
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue