package cn.edu.tju.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import服务器托管网 java.nio.charset.StandardCharsets;
@Service
public class RedisService {
@Autowired
private StringRedisTemplate redisTemplate;
public boolean setBitMap(String key, int index){
Boolean result = redisTemplate.opsForValue().setBit(key, index, true);
return result;
}
public String getBitMap(String key){
Long result = redisTemplate.execute(new RedisCallback() {
@Override
public Long doInRedis(RedisConnection connection) throws DataAccessException {
Long aLong = connection.bitCount(key.getBytes(StandardCharsets.UTF_8));
System.out.println("###########################");
System.out.println(aLong);
return aLong;
}
});
服务器托管网return String.valueOf(result);
}
}
public String bitAdd(String key1, String key2){
Long result = redisTemplate.execute(new RedisCallback() {
@Override
public Long doInRedis(RedisConnection connection) throws DataAccessException {
Long aLong = connection.bitOp(RedisStringCommands.BitOperation.AND, key1.getBytes(),
key2.getBytes());
System.out.println("###########################");
System.out.println(aLong);
return aLong;
}
});
return String.valueOf(result);
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: ChatGPT 之后,B 端产品设计会迎来颠覆式革命吗?| Liga妙谈
近日,脑机接口公司 Neuralink 宣布,其植入式脑机接口设备首次人体临床研究已被准许启动。遥想当年,我们还嘲讽罗老师「动嘴做 PPT」,谁曾想不久后我们可能连嘴都不用动🙊。 脑机接口何时会引爆人机交互革命尚未可知,但是 ChatGPT 已然掀起了大家对「…