Example #1
0
        public async Task <T> PopFromQueue <T>(string queueName, TCachePopMode popMode = TCachePopMode.Delete)
        {
            IDatabase db            = _redis.GetDatabase();
            string    queueFullName = $"queue:{queueName}";

            RedisValue value = (popMode == TCachePopMode.Delete) ? await db.ListLeftPopAsync(queueFullName) : await db.ListGetByIndexAsync(queueFullName, 0); //

            if (!value.IsNullOrEmpty)
            {
                return(JsonConvert.DeserializeObject <T>(value));
            }
            else
            {
                return(default(T));
            }
        }
Example #2
0
        public async Task <string> PopFromQueue(string queueName, TCachePopMode popMode = TCachePopMode.Delete)
        {
            IDatabase db            = _redis.GetDatabase();
            string    queueFullName = $"queue:{queueName}";

            RedisValue value = (popMode == TCachePopMode.Delete) ? await db.ListLeftPopAsync(queueFullName) : await db.ListGetByIndexAsync(queueFullName, 0); //

            if (!value.IsNullOrEmpty)
            {
                return(value.ToString());
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        public async Task <string> PullFromQueue(string queueName, bool delete = true)
        {
            TCachePopMode popMode = delete ? TCachePopMode.Delete : TCachePopMode.Get;

            return(await _cacheService.PopFromQueue(queueName, popMode));
        }