public void AddOrUpdate(CacheKey key, TimedEntityTagHeaderValue eTag) { TimedEntityTagHeaderValue test; if (!TryGetValue(key, out test)) { var cacheKey = new PersistentCacheKey { Hash = key.Hash, RoutePattern = key.RoutePattern, ETag = eTag.Tag, LastModified = eTag.LastModified }; using (var connection = new MongoEntiryStoreConnection(this.connectionString)) { connection.DocumentStore.Save(cacheKey); } } else { using (var connection = new MongoEntiryStoreConnection(this.connectionString)) { var cacheKey = connection.DocumentStore.AsQueryable().FirstOrDefault(x => x.Hash == key.Hash); if (cacheKey != null) { cacheKey.ETag = eTag.Tag; cacheKey.LastModified = eTag.LastModified; connection.DocumentStore.Save(cacheKey); } } } }
public void AddOrUpdate(CacheKey key, TimedEntityTagHeaderValue eTag) { TimedEntityTagHeaderValue test; if (!TryGetValue(key, out test)) { var cacheKey = new PersistentCacheKey { Hash = key.Hash, RoutePattern = key.RoutePattern, ETag = eTag.Tag, LastModified = eTag.LastModified, ResourceUri = key.ResourceUri }; using (var connection = new MongoEntiryStoreConnection(this.connectionString)) { connection.DocumentStore.Save(cacheKey); } } else { using (var connection = new MongoEntiryStoreConnection(this.connectionString)) { var cacheKey = connection.DocumentStore.AsQueryable().FirstOrDefault(x => x.Hash == key.Hash); if (cacheKey != null) { cacheKey.ETag = eTag.Tag; cacheKey.LastModified = eTag.LastModified; connection.DocumentStore.Save(cacheKey); } } } }