Esempio n. 1
0
        private static CacheManage _MemCache = CacheManage.Instance;   //有可能使用MemCache操作

        internal static bool GetCache(AopEnum action, AopInfo aopInfo) //Begin
        {
            switch (action)
            {
            case AopEnum.ExeNonQuery:
            case AopEnum.Insert:
            case AopEnum.Update:
            case AopEnum.Delete:
                return(false);
            }
            if (!IsCanOperateCache(aopInfo))
            {
                return(false);
            }
            string baseKey = GetBaseKey(aopInfo);
            //查看是否通知我移除
            string key = GetKey(action, aopInfo, baseKey);
            object obj = _MemCache.Get(key);

            switch (action)
            {
            case AopEnum.ExeMDataTableList:
                if (obj != null)
                {
                    List <MDataTable>           list = new List <MDataTable>();
                    Dictionary <string, string> jd   = JsonHelper.Split(obj.ToString());
                    if (jd != null && jd.Count > 0)
                    {
                        foreach (KeyValuePair <string, string> item in jd)
                        {
                            list.Add(MDataTable.CreateFrom(item.Value));
                        }
                    }
                    aopInfo.TableList = list;
                }
                break;

            case AopEnum.Select:
            case AopEnum.ExeMDataTable:
                if (obj != null)
                {
                    aopInfo.Table = MDataTable.CreateFrom(obj.ToString());
                }
                break;

            case AopEnum.ExeScalar:
                if (obj != null)
                {
                    aopInfo.ExeResult = obj;
                }
                break;

            case AopEnum.Fill:
                if (obj != null)
                {
                    MDataRow row = obj as MDataRow;
                    if (_MemCache.CacheType == CacheType.LocalCache)
                    {
                        row = row.Clone();
                    }
                    aopInfo.Row       = row;
                    aopInfo.IsSuccess = true;
                }
                break;

            case AopEnum.GetCount:
                if (obj != null)
                {
                    aopInfo.RowCount = int.Parse(obj.ToString());
                }
                break;

            case AopEnum.Exists:
                if (obj != null)
                {
                    aopInfo.ExeResult = obj;
                }
                break;
            }
            baseKey = key = null;
            return(obj != null);
        }