private void Convert(CacheItem cacheItem, CacheItemRecord record) { record.CacheKey = cacheItem.CacheKey; record.CachedOnUtc = cacheItem.CachedOnUtc; record.ContentType = cacheItem.ContentType; record.InvariantCacheKey = cacheItem.InvariantCacheKey; record.Output = cacheItem.Output; record.QueryString = cacheItem.QueryString; record.StatusCode = cacheItem.StatusCode; record.Tags = String.Join(";", cacheItem.Tags); record.Tenant = cacheItem.Tenant; record.Url = cacheItem.Url; record.ValidUntilUtc = cacheItem.ValidUntilUtc; }
public void Set(string key, CacheItem cacheItem) { var record = _repository.Table.FirstOrDefault(x => x.CacheKey == key); if (record == null) { record = new CacheItemRecord(); Convert(cacheItem, record); _repository.Create(record); return; } Convert(cacheItem, record); }
public void Set(string key, CacheItem cacheItem) { lock (String.Intern(key)) { var records = _repository.Table.Where(x => x.CacheKey == key).ToList(); var record = records.FirstOrDefault(); if (record == null) { record = new CacheItemRecord(); Convert(cacheItem, record); _repository.Create(record); return; } Convert(cacheItem, record); } }
private CacheItem Convert(CacheItemRecord record) { var cacheItem = new CacheItem(); cacheItem.CacheKey = record.CacheKey; cacheItem.CachedOnUtc = record.CachedOnUtc; cacheItem.ContentType = record.ContentType; cacheItem.InvariantCacheKey = record.InvariantCacheKey; cacheItem.Output = record.Output; cacheItem.QueryString = record.QueryString; cacheItem.StatusCode = record.StatusCode; cacheItem.Tags = record.Tags.Split(';'); cacheItem.Tenant = record.Tenant; cacheItem.Url = record.Url; cacheItem.ValidUntilUtc = record.ValidUntilUtc; return(cacheItem); }