Beispiel #1
0
        /// <summary>
        /// 从缓存中获取项
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static SqlInfo GetFromCache(string key)
        {
            SqlInfo Value = null;

            DictSqlCache.TryGetValue(key, out Value);
            return(Value);
        }
Beispiel #2
0
        /// <summary>
        /// 增加一项到缓存中
        /// </summary>
        /// <param name="key"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public static bool AddToCache(string key, SqlInfo item)
        {
            SqlInfo Value = GetFromCache(key);

            if (Value != null)
            {
                return(false);
            }
            lock (sync_obj)
            {
                DictSqlCache.Add(key, item);
            }
            return(true);
        }