redis bitMap

getBit DATA:ROPE:MONTH:UID:de4241a26adb418db0bcaf0f640945cc2022-03 31  根据key获取指定位置是否有值

# 本次项目运用在,若指定日期有数据,则存入bitMap指定的下标中:
 public static void setRopeDayRecord(String userId, String month,String day) {
        RedisBitMap bitMap = new RedisBitMap(RedisKeyEnum.跳绳日期记录.code().concat(userId).concat(month), RedisKeyEnum.跳绳日期记录.validTime());
        bitMap.setbit(Long.parseLong(day), true);
    }

public static List getRopeDayRecord(String userId, String month){
        RedisBitMap redisBitMap = new RedisBitMap(RedisKeyEnum.跳绳日期记录.code().concat(userId).concat(month));
        if (!redisBitMap.exists()){
            return new ArrayList<>();
        }
        List dayList = new ArrayList<>();
        for (int i = 1; i <= 31; i++) {
            if (redisBitMap.getbit(i)) {
                dayList.add(i);
            }
        }
        return dayList;
    }

你可能感兴趣的:(redis bitMap)