Files
youlai-boot/src/main/java/com/youlai/boot/common/constant/RedisConstants.java

78 lines
2.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.youlai.boot.common.constant;
/**
* Redis 常量
*
* @author Theo
* @since 4.3.1
*/
public interface RedisConstants {
/**
* 限流相关键
*/
interface RateLimit {
/** 接口级限流 Key示例rate_limit:api:{user}:{uri} */
String API = "rate_limit:{}:{}:{}";
/** IP 全局限流 Key示例rate_limit:ip:192.168.1.100 */
String IP = "rate_limit:ip:{}";
}
/**
* 分布式锁相关键
*/
interface Lock {
String RESUBMIT = "lock:resubmit:{}:{}"; // 防重复提交示例lock:resubmit:userIdentifier:requestIdentifier
}
/**
* 认证模块
*/
interface Auth {
// 存储访问令牌对应的用户会话信息accessToken -> UserSession
String ACCESS_TOKEN_USER = "auth:token:access:{}";
// 存储刷新令牌对应的用户会话信息refreshToken -> UserSession
String REFRESH_TOKEN_USER = "auth:token:refresh:{}";
// 用户与访问令牌的映射userId -> accessToken
String USER_ACCESS_TOKEN = "auth:user:access:{}";
// 用户与刷新令牌的映射userId -> refreshToken
String USER_REFRESH_TOKEN = "auth:user:refresh:{}";
// 已撤销 Token 的 JTI单端退出/会话注销):如果 jti 在撤销列表中,则 Token 立即无效
String BLACKLIST_TOKEN = "auth:token:blacklist:{}";
String REVOKED_JTI = BLACKLIST_TOKEN;
// 用户 Token 版本号(用于按用户失效历史 JWTtoken.tokenVersion != redis.tokenVersion => token 无效
String USER_TOKEN_VERSION = "auth:user:token_version:{}";
// 扫码登录票据上下文ticket -> QrCodeLoginContext
String QR_CODE_LOGIN = "auth:qr_code:{}";
}
/**
* 验证码模块
*/
interface Captcha {
String IMAGE_CODE = "captcha:image:{}"; // 图形验证码
String SMS_LOGIN_CODE = "captcha:sms_login:{}"; // 登录/注册通用短信验证码
String SMS_RESET_CODE = "captcha:sms_reset:{}"; // 重置密码短信验证码
String MOBILE_CODE = "captcha:mobile:{}"; // 绑定、更换手机验证码
String EMAIL_CODE = "captcha:email:{}"; // 邮箱验证码
}
/**
* 系统模块
*/
interface System {
String CONFIG = "system:config"; // 系统配置
String ROLE_PERMS = "system:role:perms"; // 系统角色和权限映射
}
/**
* 设备模块
*/
interface Device {
/** 设备在线状态示例device:online:{sn},值为 JSONkey 过期即视为离线) */
String ONLINE = "device:online:{}";
}
}