Beispiel #1
0
        /// <summary>
        /// 查找指定ID的值。若找不到,则返回默认值。
        /// </summary>
        /// <param name="uid">标识该对象的唯一ID。</param>
        /// <returns></returns>
        public static T Find(string uid)
        {
            var obj = Caches.FirstOrDefault(x => x.Key == uid);

            if (obj.Equals(default(KeyValuePair <string, T>)))
            {
                return(default(T));
            }
            else
            {
                return(obj.Value);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 获取指定的ID是否存在于缓存中。
 /// </summary>
 /// <param name="uid"></param>
 public static bool Exists(string uid)
 {
     return(!String.IsNullOrEmpty(Caches.FirstOrDefault(x => x.Key == uid).Key));
 }
Beispiel #3
0
 public SqlMapCache GetCache(string id)
 {
     return(Caches?.FirstOrDefault(p => p.Id == id));
 }
Beispiel #4
0
 /// <summary>
 ///     Gets the cache.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns></returns>
 public VideoPublisher GetCache(int id)
 {
     return(Caches.FirstOrDefault(c => c.Id == id));
 }