获取Redis的链接信息:
(RedisTemplate<String, ?> redisTemplate) {
RedisConnectionFactory connectionFactory = redisTemplate.getConnectionFactory();
(!(connectionFactory LettuceConnectionFactory)) {
System..println();
;
}
LettuceConnectionFactory lettuceConnectionFactory = (LettuceConnectionFactory) connectionFactory;
RedisConnection connection = connectionFactory.getConnection();
(connection == || connection.isClosed()) {
System..println();
} {
System..println();
String host = lettuceConnectionFactory.getHostName();
port = lettuceConnectionFactory.getPort();
System..println(+ host);
System..println(+ port);
System..println(+ connection.info());
}
}
获取指定的key:
Set<String> (RedisTemplate<String, ?> redisTemplate) {
ScanOptions scanOptions = ScanOptions.().match().count().build();
Set<String> keys = redisTemplate.execute(connection -> {
Set<[]> keysBytes = connection.keys(.getBytes());
keysBytes.stream()
.map(String::)
.collect(Collectors.());
}, );
keys;
}
获取所有key:
Set<String> (RedisTemplate<String, ?> redisTemplate,String hashKey) {
HashOperations<String, String, Object> hashOperations = redisTemplate.opsForHash();
hashOperations.keys(hashKey);
}