Get Bit
public static Boolean getBit(String key, Long offset) {
return redisTemplate.opsForValue().getBit(key, offset);
}
Set Bit
public static Boolean setBit(String key, Long offset, boolean value) {
return redisTemplate.opsForValue().setBit(key, offset, value);
}
BitField
这里要一次查多少个数据,就多少个链式调用设置
// 获取 1bit 下标从1-7的所有数据
public static ArrayList<Long> getBitList(String key) {
BitFieldSubCommands command = BitFieldSubCommands.create()
.get(BitFieldSubCommands.BitFieldType.unsigned(1)).valueAt(1)
.get(BitFieldSubCommands.BitFieldType.unsigned(1)).valueAt(2)
.get(BitFieldSubCommands.BitFieldType.unsigned(1)).valueAt(3)
.get(BitFieldSubCommands.BitFieldType.unsigned(1)).valueAt(4)
.get(BitFieldSubCommands.BitFieldType.unsigned(1)).valueAt(5)
.get(BitFieldSubCommands.BitFieldType.unsigned(1)).valueAt(6)
.get(BitFieldSubCommands.BitFieldType.unsigned(1)).valueAt(7);
return redisTemplate.opsForValue().bitField(key,command)
}