Beispiel #1
0
        public async Task <T> GetValueAsync <T>(string key)
        {
            var value = await _database.StringGetAsync(key);

            if (value.HasValue)
            {
                return(JsonSerializerExtensions.DeserializeObject <T>(value));
            }
            else
            {
                return(default(T));
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public async Task <List <T> > HashValuesAsync <T>(string key)
        {
            var result = new List <T>();

            HashEntry[] arr = await _database.HashGetAllAsync(key);

            foreach (var item in arr)
            {
                string values = item.Name;
                if (!item.Value.IsNullOrEmpty)
                {
                    var val = JsonSerializerExtensions.DeserializeObject <T>(item.Value);
                    result.Add(val);
                }
            }
            return(result);
        }