I have a distributed system where In one place i insert around 10000 items in a redis list then Call my multiple applications hook to process items. what i need is to Have some ListLeftPop type of methhod with numbers of items. It should remove items from the redis List and return to my calling application.
I am using Stackexchange.Resis.extension
My current method just for get (not pop) is
public static List<T> GetListItemRange<T>(string key, int start, int chunksize) where T : class
{
List<T> obj = default(List<T>);
try
{
if (Muxer != null && Muxer.IsConnected && Muxer.GetDatabase() != null)
{
var cacheClient = new StackExchangeRedisCacheClient(Muxer, new NewtonsoftSerializer());
var redisValues = cacheClient.Database.ListRange(key, start, (start + chunksize - 1));
if (redisValues.Length > 0)
{
obj = Array.ConvertAll(redisValues, value => JsonConvert.DeserializeObject<T>(value)).ToList();
}
}
}
catch (Exception ex)
{
Logger.Fatal(ex.Message, ex);
}
return obj;
}
For Pop and get i have find a snippet
var cacheClient = new StackExchangeRedisCacheClient(Muxer, new NewtonsoftSerializer());
var redisValues = cacheClient.ListGetFromRight<T>(key);
But it will only do for single item