redisTemplate 封装bitcout


@Repository
public class RedisServiceExtend {
@Autowired
private RedisTemplate<String, String> redisTemplate;

private static String redisCode = "utf-8";

public long bitCount(final String key) {
return redisTemplate.exec((RedisCallback<Long>) con -> con.bitCount(key.getBytes()));
}

public Long bitCount(String key, int start, int end) {
return redisTemplate.execute((RedisCallback<Long>) con -> con.bitCount(key.getBytes(), start, end));
}

public Long bitOp(RedisStringCommands.BitOperation op, String saveKey, String... desKey) {
byte[][] bytes = new byte[desKey.length][];
for (int i = 0; i < desKey.length; i++) {
bytes[i] = desKey[i].getBytes();
}
return redisTemplate.execute((RedisCallback<Long>) con -> con.bitOp(op, saveKey.getBytes(), bytes));
}

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM