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)); } }
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); } }
public async Task <string> PullFromQueue(string queueName, bool delete = true) { TCachePopMode popMode = delete ? TCachePopMode.Delete : TCachePopMode.Get; return(await _cacheService.PopFromQueue(queueName, popMode)); }