public void OnDelete(long[] ids)
 {
     if (ids == null || ids.Length == 0)
     {
         return;
     }
     RowCache.Remove(ids);
 }
Esempio n. 2
0
        //[Obsolete]
        /// <summary>
        /// 读取缓存中的数据对象的指定字段
        /// </summary>
        /// <param name="id">主键</param>
        /// <param name="args">返回的字段</param>
        /// <returns></returns>
        public T GetCache(long id, params string[] args)
        {
            if (id < 0)
            {
                return(null);
            }
            T row = null;

            if (RowCache.Get(id, ref row))
            {
                return(_Get(row, args));
            }
            var ck = id.ToString();

            if (!_lock.Add(ck))
            {
                System.Threading.Thread.Sleep(5);
                if (RowCache.Get(id, ref row))
                {
                    return(_Get(row, args));
                }
            }

            try
            {
                row = Get(id);
                if (row == null)
                {
                    RowCache.Add(id, null, 5);
                }
                else
                {
                    RowCache.Add(id, row);
                }
            }
            finally
            {
                _lock.Remove(ck);
            }
            return(_Get(row, args));
        }
 public void OnDelete(long id)
 {
     RowCache.Remove(id);
 }
 /// <summary>
 /// update 以后
 /// </summary>
 /// <param name="id"></param>
 public void OnUpdate(long id)
 {
     RowCache.Remove(id);
 }