public virtual DbCacheEntry RequestPut(string key, object value, string[] dependentEntitySets) { if (!Enabled || IsToxic(dependentEntitySets)) { return(null); } key = HashKey(key); var entry = new DbCacheEntry { Key = key, Value = value, EntitySets = dependentEntitySets, CachedOnUtc = DateTime.UtcNow }; _requestCache.Value.Put(key, entry); foreach (var entitySet in entry.EntitySets) { var lookup = RequestGetLookupSet(entitySet); lookup.Add(key); } return(entry); }
public virtual DbCacheEntry Put(string key, object value, IEnumerable <string> dependentEntitySets, TimeSpan?duration) { if (!Enabled || IsToxic(dependentEntitySets)) { return(null); } key = HashKey(key); lock (String.Intern(key)) { var entitySets = dependentEntitySets.Distinct().ToArray(); var entry = new DbCacheEntry { Key = key, Value = value, EntitySets = entitySets, CachedOnUtc = DateTime.UtcNow, Duration = duration }; _cache.Put(key, entry); foreach (var entitySet in entitySets) { var lookup = GetLookupSet(entitySet); lookup.Add(key); } return(entry); } }
public virtual bool RequestTryGet(string key, out DbCacheEntry value) { value = null; if (!Enabled) { return(false); } key = HashKey(key); value = _requestCache.Value.Get <DbCacheEntry>(key); return(value != null); }
protected void InvalidateItemUnlocked(DbCacheEntry entry) { // remove item itself from cache _cache.Remove(entry.Key); // remove this key in all lookups foreach (var set in entry.EntitySets) { var lookup = GetLookupSet(set, false); if (lookup != null) { lookup.Remove(entry.Key); } } }
public bool RequestTryGet(string key, out DbCacheEntry value) { value = null; return(false); }