Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch multiple Redis list from a single command

I am new to Redis. I want to fetch multiple lists from their keys.

My code is as follows

RedisValue[] valuelist= null;

for each( string item in Key_array){


valuelist = db.ListRange("item");
// do some calculations with the valuelist items.


}

As I am aware, this code has O(n) time complexity. Is there any way to execute this fetching from a single query.

I am using C# with StackExchange.Redis.

like image 201
Sachi Avatar asked Sep 20 '25 05:09

Sachi


1 Answers

Use StackExchange.Redis.Extensions package

retrieve multiple object with single roundtrip

var cachedData = db.GetAll<T>(new {"key1","key2","key3"});

more information is here https://github.com/imperugo/StackExchange.Redis.Extensions

I hope this help you

like image 128
Hossein Avatar answered Sep 22 '25 22:09

Hossein