3

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

Eugene
11.3k15 gold badges58 silver badges92 bronze badges
asked Nov 11, 2017 at 10:46

2 Answers 2

3

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.

answered Nov 13, 2017 at 11:07
Sign up to request clarification or add additional context in comments.

Comments

1

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
answered Nov 13, 2017 at 7:13

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.