| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package com.zhentao.constant;
- /**
- * Redis缓存Key常量
- */
- public class RedisKeyConstants {
-
- /**
- * 红娘详情缓存Key前缀
- * 格式:matchmaker:detail:{matchmakerId}
- */
- public static final String MATCHMAKER_DETAIL = "matchmaker:detail:";
-
- /**
- * 红娘列表缓存Key前缀
- * 格式:matchmaker:list:{type}:{level}:{provinceId}:{cityId}:{pageNum}:{pageSize}
- */
- public static final String MATCHMAKER_LIST = "matchmaker:list:";
-
- /**
- * 全职红娘列表缓存Key前缀
- * 格式:matchmaker:formal:{pageNum}:{pageSize}
- */
- public static final String MATCHMAKER_FORMAL_LIST = "matchmaker:formal:";
-
- /**
- * 热门红娘列表缓存Key
- */
- public static final String MATCHMAKER_HOT_LIST = "matchmaker:hot:list";
-
- /**
- * 红娘详情缓存过期时间(秒)- 1小时
- */
- public static final long MATCHMAKER_DETAIL_EXPIRE = 3600;
-
- /**
- * 红娘列表缓存过期时间(秒)- 30分钟
- */
- public static final long MATCHMAKER_LIST_EXPIRE = 1800;
-
- /**
- * 热门红娘列表缓存过期时间(秒)- 30分钟
- */
- public static final long MATCHMAKER_HOT_EXPIRE = 1800;
-
- /**
- * 构建红娘详情缓存Key
- */
- public static String buildMatchmakerDetailKey(Integer matchmakerId) {
- return MATCHMAKER_DETAIL + matchmakerId;
- }
-
- /**
- * 构建红娘列表缓存Key
- */
- public static String buildMatchmakerListKey(Integer type, Integer level, Integer provinceId,
- Integer cityId, String keyword, Integer pageNum, Integer pageSize) {
- // 将keyword转换为缓存键的一部分,如果为空则使用"all"
- String keywordPart = (keyword != null && !keyword.trim().isEmpty()) ? keyword.trim() : "all";
- return MATCHMAKER_LIST +
- (type != null ? type : "all") + ":" +
- (level != null ? level : "all") + ":" +
- (provinceId != null ? provinceId : "all") + ":" +
- (cityId != null ? cityId : "all") + ":" +
- keywordPart + ":" +
- pageNum + ":" + pageSize;
- }
-
- /**
- * 构建全职红娘列表缓存Key
- */
- public static String buildFormalListKey(Integer pageNum, Integer pageSize) {
- return MATCHMAKER_FORMAL_LIST + pageNum + ":" + pageSize;
- }
- }
|