Ejemplo n.º 1
0
 public int RemoveItemFromQueue <T>(string queueId, T queueItem)
 {
     using (var Redis = RedisClientManager.GetClient())
     {
         return(Redis.RemoveItemFromList(RedisKeyFactory.QueueKey <T>(queueId), JsonConvert.SerializeObject(queueItem)));
     }
 }
Ejemplo n.º 2
0
 public int GetLengthOfQueue <T>(string queueId)
 {
     using (var Redis = RedisClientManager.GetReadOnlyClient())
     {
         return(Redis.GetListCount(RedisKeyFactory.QueueKey <T>(queueId)));
     }
 }
Ejemplo n.º 3
0
 public void AddItemToQueue <T>(string queueId, T queueItem)
 {
     using (var Redis = RedisClientManager.GetClient())
     {
         Redis.AddItemToList(RedisKeyFactory.QueueKey <T>(queueId), JsonConvert.SerializeObject(queueItem));
     }
 }
Ejemplo n.º 4
0
        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));
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }