点滴记录项目中生成redisKey的工具
public class RedisUtils {
//分隔符
public final static String split = ":";
public static String getRedisKey(String... name) {
StringBuffer sb = new StringBuffer();
for (String str : name) {
if (StringUtils.isNotBlank(str)) {
sb.append(str);
sb.append(split);
}
}
sb = sb.deleteCharAt(sb.lastIndexOf(split));
return sb.toString();
}
public static String getRedisKeyJoin(String... name){
ArrayList<String> strlist = Lists.newArrayList();
for (String str : name) {
if (StringUtils.isNotBlank(str)) {
strlist.add(str);
}
}
return Joiner.on("_").join(strlist);
}
}