I want to get all keys start with 460 or 45412.
keys 460* combine keys 45412*
I try the method in this Link: https://redis.io/commands/keys but Failed
2 Answers 2
I finally Use Jedis to get all result by Set DataStructure
Set<String> FirstSet = js.keys("460*");
Set<String> SecondSet = js.keys("45412*");
SecondSet.addAll(FirstSet );
The Second Set is what I want.
Comments
There is no combine option in Redis.
And keys command is not supposed to be used on application level, it is slow. Instead you can use appropriate type (hash or zset or its combination, depending on what you need)
Anyway, if you want to get keys by two patterns you can just call keys a couple times and combine results:
cat <(redis-cli -n 0 keys "460*") <(redis-cli -n 0 keys "45412*") > keys.txt