叙述
项目中需要往 Redis 中写入和读取数据时,要以目录形式进行。
解决方案
key设置,可以参考以下:
/**
* redis key 接口参数
* key:key值
* expiredate:过期时间
*/
public interface RedisKey {
long START = 0L;
long END = -1L;
String TOKEN = "token:token-";
int TOKEN_EXPIRE_DATE = 24 * 3600;
String COMPANY_TREE_ALL = "company:companyTree-all";
String COMPANY_TREE = "company:companyTree-";
String REGION_TREE_ALL = "company:regionTree-all";
String REGION_TREE = "company:regionTree-";
String DEPARTMENT_TREE = "department:departmentTree-";
String DEPARTMENT_LIST = "department:departmentList-";
int DATA_EXPIRE_DATE = 8 * 3600;
}
请看
company:companyTree-all
company:companyTree-all (company指的是目录名称 companyTree-all是目录内的key)