com.gitee.fufu669.utils.CacheRedisKeyUtil Maven / Gradle / Ivy
package com.gitee.fufu669.utils;
import com.gitee.fufu669.common.CacheKeyCommon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @author wangfupeng */
public class CacheRedisKeyUtil {
public static final Logger logger = LoggerFactory.getLogger(CacheRedisKeyUtil.class);
public static String getLockWithRedisAopLockKeyRedisKey(String key) {
return "lock:"+key;
}
public static String getPasswordRedisKey(String key) {
if(key==null) {
return CacheKeyCommon.PASSWORD + "null";
}
if (key.length() > CacheKeyCommon.REDIS_KEY_EXCEED_MAX_VALUE) {
return CacheKeyCommon.PASSWORD + "" + key.substring(0, CacheKeyCommon.REDIS_KEY_EXCEED_MAX_VALUE);
} else {
return CacheKeyCommon.PASSWORD + "" + key;
}
}
public static String getTokenRedisKey(String key) {
if (key == null) {
return CacheKeyCommon.TOKEN + "null";
}
if (key.length() > CacheKeyCommon.REDIS_KEY_EXCEED_MAX_VALUE) {
return CacheKeyCommon.TOKEN + "" + key.substring(0, CacheKeyCommon.REDIS_KEY_EXCEED_MAX_VALUE);
} else {
return CacheKeyCommon.TOKEN + "" + key;
}
}
}