コード例 #1
0
 /// <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);
     }
 }
コード例 #2
0
ファイル: MemoryCache.cs プロジェクト: hongweichang/NFinal2
        public override bool HasKey(string key)
        {
#if !(NETCORE || CORE)
            return(_memoryCache.Contains(key));
#else
            object obj;
            return(_memoryCache.TryGetValue(key, out obj));
#endif
        }
コード例 #3
0
        public bool Exists(string key)
        {
#if !CORE_CLR
            return(_innerCache.Contains(key));
#else
            object result;

            return(_innerCache.TryGetValue(key, out result));
#endif
        }
コード例 #4
0
            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);
            }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: DBGuiInterface.cs プロジェクト: mlof/ED-IBE
        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);
        }
コード例 #7
0
 /// <inheritdoc />
 public bool Contains(string key)
 {
     return(cache.Contains(key));
 }
コード例 #8
0
 public bool Exists(string key)
 {
     return(_innerCache.Contains(key));
 }
コード例 #9
0
 /// <inheritdoc />
 public bool Contains(string key)
 {
     return(_memoryCache.Contains(key));
 }
コード例 #10
0
ファイル: MemoryCache.cs プロジェクト: ilkerhalil/KVLite
        /// <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));
        }
コード例 #11
0
 public static bool Exists(string key)
 {
     System.Runtime.Caching.MemoryCache cache = System.Runtime.Caching.MemoryCache.Default;
     return(cache.Contains(TransformKey(key)));
 }