/// <summary> /// Add an object to the response cache /// </summary> /// <param name="url">full url used to obtain the response</param> /// <param name="response">the response to cache</param> public void Add(string url, ResponseObject response) { response.Url = url; string hash = GetHash(url); lock (_objectLock) { if (cache.ContainsKey(hash)) { cache.Remove(hash); } response.Url = url; GwApi.Logger.Info("Adding {0} to Cache", response.GetType()); cache.Add(hash, response); } }
public Task AddAsync(string key, ResponseObject response) { return Task.Run(() => { response.Url = key; string hash = GetHash(key); lock (_objectLock) { if (cache.ContainsKey(hash)) { cache.Remove(hash); } response.Url = key; GwApi.Logger.Info("Adding {0} to Cache", response.GetType()); cache.Add(hash, response); } }); }