public void Clear(string cacheKey) { ValueCacheKey key = GetRequestCacheKey(cacheKey); if (key != null) { /* remove this cache key */ var cacheInstance = RequestVariableForCache.Value; cacheInstance.TryRemove(key, out object removed); } }
public T Get <T>(string cacheKey) { ValueCacheKey key = GetRequestCacheKey(cacheKey); object result = null; if (key != null) { var cacheInstance = requestVariableForCache.Value; /* look for the stored value */ if (cacheInstance.TryGetValue(key, out result)) { return((T)result); } } return(default(T)); }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (GetType() != obj.GetType()) { return(false); } ValueCacheKey other = (ValueCacheKey)obj; if (rvKey == null) { if (other.rvKey != null) { return(false); } } else if (!rvKey.Equals(other.rvKey)) { return(false); } if (valueCacheKey == null) { if (other.valueCacheKey != null) { return(false); } } else if (!valueCacheKey.Equals(other.valueCacheKey)) { return(false); } return(true); }
internal T PutIfAbsent <T>(string cacheKey, T f) { ValueCacheKey key = GetRequestCacheKey(cacheKey); object result = null; if (key != null) { var cacheInstance = requestVariableForCache.Value; result = cacheInstance.GetOrAdd(key, f); if (f.Equals(result)) { return(default(T)); } else { return((T)result); } } return(default(T)); }
public CacheKey Key(string id) { var key = new ValueCacheKey(this, id); _dKeys[id] = key; return key; }