public int RemoveItemFromQueue <T>(string queueId, T queueItem) { using (var Redis = RedisClientManager.GetClient()) { return(Redis.RemoveItemFromList(RedisKeyFactory.QueueKey <T>(queueId), JsonConvert.SerializeObject(queueItem))); } }
public int GetLengthOfQueue <T>(string queueId) { using (var Redis = RedisClientManager.GetReadOnlyClient()) { return(Redis.GetListCount(RedisKeyFactory.QueueKey <T>(queueId))); } }
public void AddItemToQueue <T>(string queueId, T queueItem) { using (var Redis = RedisClientManager.GetClient()) { Redis.AddItemToList(RedisKeyFactory.QueueKey <T>(queueId), JsonConvert.SerializeObject(queueItem)); } }
public T RetrieveItemFromQueue <T>(string queueId) { using (var Redis = RedisClientManager.GetClient()) { var result = Redis.BlockingDequeueItemFromList(RedisKeyFactory.QueueKey <T>(queueId), new TimeSpan(0)); if (result != null) { return(JsonConvert.DeserializeObject <T>(result)); } return(default(T)); } }
public List <T> GetAllItemsFromQueue <T>(string queueId) { using (var Redis = RedisClientManager.GetReadOnlyClient()) { var result = Redis.GetAllItemsFromList(RedisKeyFactory.QueueKey <T>(queueId)); List <T> items = new List <T>(); if (result != null) { foreach (var json in result) { items.Add(JsonConvert.DeserializeObject <T>(json)); } return(items); } return(items); } }