Exemplo n.º 1
0
        public void Add(string key, T value)
        {
            try
            {
                if (_useRedisCache == false || _dataCache == null)
                {
                    _memoryCache.TryAdd(key, value);
                    return;
                }

                var data = _serializer.Serialize(value);
                _dataCache.HashSet(_dictionaryName, key, data);
            }
            catch (Exception)
            {
            }
        }
        public void UpdateListItem <T>(string listName, int index, T listitem)
        {
            try
            {
                var redisItem = _serializer.Serialize(listitem);

                if (_useDistributedCache)
                {
                    _rediscache.HashSet(listName, new[] { new HashEntry(index, redisItem) });
                }

                // Update the item in memory
                var memList = GetMemory <List <T> >(listName);
                if (memList.Count > index)
                {
                    memList[index] = listitem;
                }
            }
            catch (Exception)
            {
            }
        }