예제 #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));
            }
        }
예제 #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);
            }
        }
예제 #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));
        }