ERR unknown command keys
After switching to redis, I found an error in the keys command. The reason for query is as follows:
The reason may be: the keys command is used for global query. It is generally not recommended to use it, so the replacement command can be configured.
Solution: Check if this command is in the configuration disabled
rename-command FLUSHALL "" Clear all library data
rename-command FLUSHDB "" �
rename-command KEYS ""
If there is comment,
However, because it is using a unified deployment redis, it is impossible to modify the operation, so it has to modify the operation involving the kes command
Use scan to get redisKey
@Autowired public RedisTemplate redisTemplate; public Set<String> scan(String matchKey) { Set<String> keys = new HashSet<>(); ScanOptions scanOptions = ().match(matchKey).count(1000).build(); Cursor<byte[]> cursor = (Cursor<byte[]>) (redisConnection -> (scanOptions), true); RedisSerializer redisSerializer = (); while (()) { (((()))); } return keys; }
This is the end of this article about the implementation of redis query keys errors. For more related redis query keys errors, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!