/// <summary> /// Delete cache value from key /// </summary> /// <param name="key"></param> public static void Delete(string key) { System.Runtime.Caching.MemoryCache memoryCache = System.Runtime.Caching.MemoryCache.Default; if (memoryCache.Contains(key)) { memoryCache.Remove(key); } }
public override bool HasKey(string key) { #if !(NETCORE || CORE) return(_memoryCache.Contains(key)); #else object obj; return(_memoryCache.TryGetValue(key, out obj)); #endif }
public bool Exists(string key) { #if !CORE_CLR return(_innerCache.Contains(key)); #else object result; return(_innerCache.TryGetValue(key, out result)); #endif }
public static object Value(string key) { string NewKey = TransformKey(key); System.Runtime.Caching.MemoryCache cache = System.Runtime.Caching.MemoryCache.Default; if (cache.Contains(NewKey)) { return(cache[NewKey]); } return(string.Empty); }
public static string GetString(string name) { string result = null; if (x.Contains(name)) { var obj = x[name]; result = (string)(obj == DBNull.Value ? null : obj); } else { using (var db = new CC.Data.ccEntities()) { try { var item = db.GlobalStrings.SingleOrDefault(f => f.Name == name); if (item != null) { result = item.Value; } } catch (Exception) { return(name + " - value not found"); } } if (result == null) { x.Set(name, DBNull.Value, new System.Runtime.Caching.CacheItemPolicy()); } else { x.Set(name, result, new System.Runtime.Caching.CacheItemPolicy()); } } return(result); }
public T GetIniValue <T>(string initKey, string defaultValue = "", bool allowEmptyValue = true, bool rewriteOnBadCast = true, Boolean cached = true) { T retValue; if (cached) { if (m_SettingsCache.Contains(m_InitGroup + "|" + initKey)) { retValue = (T)m_SettingsCache.Get(m_InitGroup + "|" + initKey); } else { retValue = m_DBCon.getIniValue <T>(m_InitGroup, initKey, defaultValue, allowEmptyValue, rewriteOnBadCast); m_SettingsCache.Add(m_InitGroup + "|" + initKey, retValue, DateTime.UtcNow + new TimeSpan(0, 0, 1, 0)); } } else { retValue = m_DBCon.getIniValue <T>(m_InitGroup, initKey, defaultValue, allowEmptyValue, rewriteOnBadCast); m_SettingsCache.Add(m_InitGroup + "|" + initKey, retValue, DateTime.UtcNow + new TimeSpan(0, 0, 1, 0)); } return(retValue); }
/// <inheritdoc /> public bool Contains(string key) { return(cache.Contains(key)); }
public bool Exists(string key) { return(_innerCache.Contains(key)); }
/// <inheritdoc /> public bool Contains(string key) { return(_memoryCache.Contains(key)); }
/// <summary> /// Determines whether cache contains the specified partition and key. /// </summary> /// <param name="partition">The partition.</param> /// <param name="key">The key.</param> /// <returns>Whether cache contains the specified partition and key.</returns> /// <remarks>Calling this method does not extend sliding items lifetime.</remarks> protected override bool ContainsInternal(string partition, string key) { var maybeCacheKey = SerializeCacheKey(partition, key); return(_store.Contains(maybeCacheKey)); }
public static bool Exists(string key) { System.Runtime.Caching.MemoryCache cache = System.Runtime.Caching.MemoryCache.Default; return(cache.Contains(TransformKey(key))); }