Reputation: 1
I have a query regarding redis two operations performing in single command like String command and Hash command at a time for fetching their values from Redis Server.
SET key1 value1 SET key2 value2
HSET key3 field3 value3 HSET key4 field4 value4
Suppose we want to get multiple String value using MGET and same ways in Hashes using HMGET
but now we want Single String value and Hashes value in single command.
like want to get 'value1' and 'Value3' respective String and Hashes keys.
Please Explain this query.
I tried to get from HMGET command for fetching miscellanies value for multiple operations.
Upvotes: 0
Views: 156
Reputation: 4312
I'm sorry to say that there's no command to do this. You have three options that approximate what you'd like in descending order of closeness:
This is probably the closest. You write a function that you can call that does what you want. There are a couple of ways to do this that are detailed in the link above. Functions are easier but require Redis Stack 7 or higher. Scripts are older and thus are available in older versions of Redis.
You can shove multiple commands into Redis without waiting for a response. Then get the responses all at once.
Transactions allow you to execute multiple commands atomically. There are still several round trips to the server, but the commands are executed all at once.
All of these are fairly large topics to explore, but hopefully this gives you a decent direction to figure your problem out.
Upvotes: 1