更换缓存前缀 双冒号太别扭了 密集恐惧症

v1.4.1
Parker 4 years ago
parent 6cb7589feb
commit 955d640b93

@ -25,12 +25,12 @@ package org.opsli.common.constants;
public interface DictConstants {
/** 缓存前缀 NAME */
String CACHE_PREFIX_NAME = "dict::name::";
String CACHE_PREFIX_NAME = "dict:name:";
/** 缓存前缀 VALUE*/
String CACHE_PREFIX_VALUE = "dict::value::";
String CACHE_PREFIX_VALUE = "dict:value:";
/** 缓存前缀 LIST*/
String CACHE_PREFIX_LIST = "dict::list::";
String CACHE_PREFIX_LIST = "dict:list:";
}

@ -110,7 +110,7 @@ public abstract class BaseRestController <T extends BaseEntity, E extends ApiWra
// 如果开启缓存 先从缓存读
if(hotDataFlag){
// 缓存Key
String cacheKey = CacheConstants.HOT_DATA_PREFIX +"::"+ id;
String cacheKey = CacheConstants.HOT_DATA_PREFIX +":"+ id;
model = WrapperUtil.transformInstance(
CacheUtil.getTimed(entityClazz, cacheKey)

@ -299,7 +299,7 @@ public class CacheUtil {
if(isSaveLocal){
// 获得缓存Json
cacheJson = ehCachePlugin.get(CacheConstants.EHCACHE_SPACE,
cacheKey +"::"+ field, JSONObject.class);
cacheKey +":"+ field, JSONObject.class);
if(cacheJson != null){
return cacheJson.get(JSON_KEY);
}
@ -312,7 +312,7 @@ public class CacheUtil {
if(isSaveLocal){
//存入EhCache
ehCachePlugin.put(CacheConstants.EHCACHE_SPACE,
cacheKey + "::" + field, cacheJson);
cacheKey + ":" + field, cacheJson);
}
}
@ -474,7 +474,7 @@ public class CacheUtil {
String cacheKey = CacheUtil.handleKey(CacheType.EDEN_HASH, key);
// 删除 EhCache
boolean ehcacheRet = ehCachePlugin.delete(CacheConstants.EHCACHE_SPACE,cacheKey +"::"+ field);
boolean ehcacheRet = ehCachePlugin.delete(CacheConstants.EHCACHE_SPACE,cacheKey +":"+ field);
if(ehcacheRet){
count--;
}
@ -504,7 +504,7 @@ public class CacheUtil {
public static boolean putNilFlag(String key) {
try {
// 处理缓存 key
String cacheKey = CacheUtil.handleKey(NIL_FLAG_PREFIX + "::" + key);
String cacheKey = CacheUtil.handleKey(NIL_FLAG_PREFIX + ":" + key);
// 存入Redis
return redisPlugin.put(cacheKey, 1, TTL_NIL_DATA_TIME);
}catch (Exception e){
@ -523,7 +523,7 @@ public class CacheUtil {
public static boolean delNilFlag(String key) {
try {
// 处理缓存 key
String cacheKey = CacheUtil.handleKey(NIL_FLAG_PREFIX + "::" + key);
String cacheKey = CacheUtil.handleKey(NIL_FLAG_PREFIX + ":" + key);
// 删除Redis
return redisPlugin.del(cacheKey);
}catch (Exception e){
@ -543,7 +543,7 @@ public class CacheUtil {
public static boolean hasNilFlag(String key) {
try {
// 处理缓存 key
String cacheKey = CacheUtil.handleKey(NIL_FLAG_PREFIX + "::" + key);
String cacheKey = CacheUtil.handleKey(NIL_FLAG_PREFIX + ":" + key);
// 判断Redis 是否 包含当前Nil值
return redisPlugin.get(cacheKey) != null;
}catch (Exception e){
@ -571,7 +571,7 @@ public class CacheUtil {
* @return String
*/
public static String handleKey(CacheType cacheType, String key){
return PREFIX_NAME + cacheType.getName() + "::" +
return PREFIX_NAME + cacheType.getName() + ":" +
key;
}
@ -649,7 +649,7 @@ public class CacheUtil {
public void init(CacheProperties cacheProperties){
if(cacheProperties != null){
// 获得 超级管理员
CacheUtil.PREFIX_NAME = Convert.toStr(cacheProperties.getPrefix(), "opsli") + "::";
CacheUtil.PREFIX_NAME = Convert.toStr(cacheProperties.getPrefix(), "opsli") + ":";
}
}

@ -85,9 +85,9 @@ public class DictHandler implements RedisPushSubHandler{
// 解析 key
String ehKeyByName = CacheUtil.handleKey(CacheType.EDEN_HASH, DictConstants.CACHE_PREFIX_NAME +
dictWrapperModel.getTypeCode() + "::" + dictWrapperModel.getDictName());
dictWrapperModel.getTypeCode() + ":" + dictWrapperModel.getDictName());
String ehKeyByValue = CacheUtil.handleKey(CacheType.EDEN_HASH, DictConstants.CACHE_PREFIX_VALUE +
dictWrapperModel.getTypeCode() + "::" + dictWrapperModel.getDictValue());
dictWrapperModel.getTypeCode() + ":" + dictWrapperModel.getDictValue());
// 缓存更新
if(CacheHandleType.UPDATE == type){

@ -55,7 +55,7 @@ public class HotDataHandler implements RedisPushSubHandler{
}
// 拼装缓存key
String cacheName = CacheUtil.handleKey(CacheConstants.HOT_DATA_PREFIX +"::"+ key);
String cacheName = CacheUtil.handleKey(CacheConstants.HOT_DATA_PREFIX +":"+ key);
if(CacheHandleType.UPDATE == type){
ehCachePlugin.put(CacheConstants.EHCACHE_SPACE, cacheName, value);

@ -93,7 +93,7 @@ public class CacheDataAop {
for (CacheDataEntity cacheDataEntity : cacheDataEntityList) {
// 更新缓存数据
// 热点数据
boolean putRet = CacheUtil.put(CacheConstants.HOT_DATA_PREFIX +"::"+ cacheDataEntity.getKey(),
boolean putRet = CacheUtil.put(CacheConstants.HOT_DATA_PREFIX +":"+ cacheDataEntity.getKey(),
returnValue);
if(putRet){
// 广播缓存数据 - 通知其他服务器同步数据
@ -143,7 +143,7 @@ public class CacheDataAop {
for (CacheDataEntity cacheDataEntity : cacheDataEntityList) {
// 更新缓存数据 - 删除缓存
boolean delRet = CacheUtil.del(CacheConstants.HOT_DATA_PREFIX +"::"+ cacheDataEntity.getKey());
boolean delRet = CacheUtil.del(CacheConstants.HOT_DATA_PREFIX +":"+ cacheDataEntity.getKey());
if(delRet){
// 广播缓存数据 - 通知其他服务器同步数据
redisPlugin.sendMessage(

@ -32,7 +32,7 @@ public class RedisCacheManager implements CacheManager {
/**
* The Redis key prefix for caches
*/
public static final String DEFAULT_CACHE_KEY_PREFIX = "shiro::cache::";
public static final String DEFAULT_CACHE_KEY_PREFIX = "shiro:cache:";
private String keyPrefix = DEFAULT_CACHE_KEY_PREFIX;
public static final String DEFAULT_PRINCIPAL_ID_FIELD_NAME = "authCacheKey or id";
@ -45,7 +45,7 @@ public class RedisCacheManager implements CacheManager {
Cache cache = caches.get(name);
if (cache == null) {
cache = new RedisCache<K, V>(redisManager,keyPrefix + name + "::", expire, principalIdFieldName);
cache = new RedisCache<K, V>(redisManager,keyPrefix + name + ":", expire, principalIdFieldName);
caches.put(name, cache);
}
return cache;

@ -25,10 +25,10 @@ package org.opsli.core.security.shiro.utils;
public class RedisKeys {
public static String getSysConfigKey(String key){
return "system::config::" + key;
return "system:config:" + key;
}
public static String getShiroSessionKey(String key){
return "sessionid::" + key;
return "sessionid:" + key;
}
}

@ -58,7 +58,7 @@ public class CaptchaUtil {
private static final List<CaptchaStrategy> CAPTCHA_STRATEGY_LIST;
/** 缓存前缀 */
private static final String PREFIX = "temp::captcha::";
private static final String PREFIX = "temp:captcha:";
/** 默认验证码保存 5 分钟 */
private static final int TIME_OUT = 300;
/** Redis插件 */

@ -72,7 +72,7 @@ public class DictUtil {
// 缓存Key
String cacheKey = DictConstants.CACHE_PREFIX_VALUE + typeCode;
// 缓存Key + VALUE
String cacheKeyVal = cacheKey + "::" + dictValue;
String cacheKeyVal = cacheKey + ":" + dictValue;
// 字典名称
String dictName = null;
@ -152,7 +152,7 @@ public class DictUtil {
// 缓存Key
String cacheKey = DictConstants.CACHE_PREFIX_NAME + typeCode;
// 缓存Key + VALUE
String cacheKeyVal = cacheKey + "::" + dictName;
String cacheKeyVal = cacheKey + ":" + dictName;
// 字典值
String dictValue = null;
@ -369,9 +369,9 @@ public class DictUtil {
}
boolean hasNilFlagByName = CacheUtil.hasNilFlag(DictConstants.CACHE_PREFIX_NAME +
model.getTypeCode() + "::" + model.getDictName());
model.getTypeCode() + ":" + model.getDictName());
boolean hasNilFlagByValue = CacheUtil.hasNilFlag(DictConstants.CACHE_PREFIX_VALUE +
model.getTypeCode() + "::" + model.getDictValue());
model.getTypeCode() + ":" + model.getDictValue());
DictWrapper dictByName = CacheUtil.getHash(DictWrapper.class,
DictConstants.CACHE_PREFIX_NAME + model.getTypeCode(),
@ -386,7 +386,7 @@ public class DictUtil {
count++;
// 清除空拦截
boolean tmp = CacheUtil.delNilFlag(DictConstants.CACHE_PREFIX_NAME +
model.getTypeCode() + "::" + model.getDictName());
model.getTypeCode() + ":" + model.getDictName());
if(tmp){
count--;
}
@ -396,7 +396,7 @@ public class DictUtil {
count++;
// 清除空拦截
boolean tmp = CacheUtil.delNilFlag(DictConstants.CACHE_PREFIX_VALUE +
model.getTypeCode() + "::" + model.getDictValue());
model.getTypeCode() + ":" + model.getDictValue());
if(tmp){
count--;
}

@ -45,7 +45,7 @@ import static org.opsli.common.constants.OrderConstants.UTIL_ORDER;
public class MenuUtil {
/** 前缀 */
public static final String PREFIX_CODE = "menu::code::";
public static final String PREFIX_CODE = "menu:code:";
/** Redis插件 */

@ -45,7 +45,7 @@ import static org.opsli.common.constants.OrderConstants.UTIL_ORDER;
public class OrgUtil {
/** 前缀 */
public static final String PREFIX_CODE = "org::userId::";
public static final String PREFIX_CODE = "org:userId:";
/** Redis插件 */

@ -48,7 +48,7 @@ public class SearchHisUtil {
/** 搜索历史缓存数据KEY */
private static final int DEFAULT_COUNT = 10;
private static final String CACHE_PREFIX = "his::username::";
private static final String CACHE_PREFIX = "his:username:";
/** Redis插件 */
private static RedisPlugin redisPlugin;
@ -71,7 +71,7 @@ public class SearchHisUtil {
// 获得当前用户
UserModel user = UserUtil.getUser();
String cacheKey = CacheUtil.getPrefixName() + CACHE_PREFIX + user.getUsername() + "::" + key;
String cacheKey = CacheUtil.getPrefixName() + CACHE_PREFIX + user.getUsername() + ":" + key;
return redisPlugin.zReverseRange(cacheKey, 0, count - 1);
}
@ -97,7 +97,7 @@ public class SearchHisUtil {
}
String cacheKey = CacheUtil.getPrefixName() + CACHE_PREFIX + user.getUsername() + "::" + key;
String cacheKey = CacheUtil.getPrefixName() + CACHE_PREFIX + user.getUsername() + ":" + key;
String val = values[0];
// 记录

@ -45,7 +45,7 @@ import static org.opsli.common.constants.OrderConstants.UTIL_ORDER;
public class TenantUtil {
/** 前缀 */
public static final String PREFIX_CODE = "tenant::id::";
public static final String PREFIX_CODE = "tenant:id:";
/** Redis插件 */

@ -61,11 +61,11 @@ public class UserTokenUtil {
/** token 缓存名 */
public static final String TOKEN_NAME = TokenConstants.ACCESS_TOKEN;
/** 缓存前缀 */
private static final String TICKET_PREFIX = "ticket::";
private static final String TICKET_PREFIX = "ticket:";
/** 账号失败次数 */
public static final String ACCOUNT_SLIP_COUNT_PREFIX = "account::slip::count::";
public static final String ACCOUNT_SLIP_COUNT_PREFIX = "account:slip:count:";
/** 账号失败锁定KEY */
public static final String ACCOUNT_SLIP_LOCK_PREFIX = "account::slip::lock::";
public static final String ACCOUNT_SLIP_LOCK_PREFIX = "account:slip:lock:";
/** 限制登录数量 -1 为无限大 */
public static final int ACCOUNT_LIMIT_INFINITE = -1;
/** 登录配置信息 */

@ -55,11 +55,11 @@ import static org.opsli.common.constants.OrderConstants.UTIL_ORDER;
public class UserUtil {
/** 前缀 */
public static final String PREFIX_ID = "userId::";
public static final String PREFIX_ID_ROLES = "userId::roles::";
public static final String PREFIX_ID_PERMISSIONS = "userId::permissions::";
public static final String PREFIX_ID_MENUS = "userId::menus::";
public static final String PREFIX_USERNAME = "username::";
public static final String PREFIX_ID = "userId:";
public static final String PREFIX_ID_ROLES = "userId:roles:";
public static final String PREFIX_ID_PERMISSIONS = "userId:permissions:";
public static final String PREFIX_ID_MENUS = "userId:menus:";
public static final String PREFIX_USERNAME = "username:";
/** Redis插件 */

@ -27,7 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class RedisLock {
private static final String LOCK_PREFIX = "lock::";
private static final String LOCK_PREFIX = "lock:";
/** 锁名称 */
private String lockName;

@ -53,7 +53,7 @@ import java.util.List;
public class RedisLockImpl implements RedisLockPlugins {
/** 锁前缀 */
private static final String LOCK_NAME_PREFIX = "lock::";
private static final String LOCK_NAME_PREFIX = "lock:";
@Autowired
private RedisPlugin redisPlugin;

@ -11,7 +11,7 @@ package org.opsli.plugins.redis.pushsub.receiver;
*/
public abstract class BaseReceiver {
public static final String BASE_CHANNEL = "listener::msg::";
public static final String BASE_CHANNEL = "listener:msg:";
private final String channel;
public BaseReceiver(String channel){

@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class RedissonLock {
private static final String PREFIX = "lock::";
private static final String PREFIX = "lock:";
private RedissonManager redissonManager;
private RedissonClient redisson;

@ -17,7 +17,7 @@ public @interface DistributedLock {
/**
*
*/
String value() default "opsli::redisson";
String value() default "opsli:redisson";
/**
*

Loading…
Cancel
Save