RedisKey的生成工具类

点滴记录项目中生成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 strlist = Lists.newArrayList();
    	for (String str : name) {
			if (StringUtils.isNotBlank(str)) {
				strlist.add(str);
			}
		}
    	return Joiner.on("_").join(strlist);
    }
}

你可能感兴趣的:(redis)