I want to get all the sets from Redis using a list of keys in single call. As per the documentation, Redis provides SSCAN command for that but as I am using StackExchange.Redis as a Redis adapter, I guess this command does not have any such method in this adapter. So there two things I am looking for:
- I looking forward to execute SSCAN using the LUA script but was not able to find any such example over the internet. Can anyone share how to call SSCAN from LUA with multiple SET Keys.
- Also for the StackExchange.Redis, if I execute multiple SetMembers() in a transaction, is it similar to use SSCAN() command using LUA script?
Thanks
I'm unclear about the specific requirements here, so there are probably several ways to do that. The simplest is by calling
SUNION
, which will dedupe and return the results w/o order.Another option is to use a Lua script, such as:
redis-cli example (sorry, .NET isn't my forte):
Note: if your Sets have a lot of members then getting all of them, regardless the approach, is going to be "expensive" - reconsider the need for that.
The sample C# code to get many SETs in a single call is as following: I am using StackExchange.Redis as a Redis connector:
}
I hope it will help the C# developers looking for the solution. Thanks to Mgravell from SE.Redis dev team for helping me by his suggestions. More discussion could be found here at GitHub How to get multiple sets by passing set key list in a single call