Beispiel #1
0
        public static T GetRecordCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, Key ID, TimeSpan timeSpan, bool isCache = true) where D : DalBase <T, Key> where T : class, new()
        {
            string cacheKey = string.Format(objBizBase.Dal.TableName.ToLower() + "_" + ID.ToString(), new object[0]);

            if (!isCache)
            {
                cacheKey.DeleteCacheMemcached();
                return(objBizBase.GetRecord(ID));
            }
            string str2 = ConfigHelper.GetValue("Memcache_ForeverTB", "");

            if (!(string.IsNullOrWhiteSpace(str2) || !str2.ToLower().Contains(objBizBase.Dal.TableName.ToLower())))
            {
                timeSpan = new TimeSpan(ConfigHelper.GetIntValue("RecordCacheForeverHours", 0x30), 0, 0);
            }
            T cacheMemcached = cacheKey.GetCacheMemcached <T>();

            if (cacheMemcached == null)
            {
                cacheMemcached = objBizBase.GetRecord(ID);
                if (cacheMemcached == null)
                {
                    return(cacheMemcached);
                }
                cacheMemcached.SetCacheMemcached(cacheKey, timeSpan);
            }
            return(cacheMemcached);
        }
Beispiel #2
0
 public static void DeleteCacheIDString <D, T, Key>(this BizBase <D, T, Key> objBizBase, string IDString) where D : DalBase <T, Key> where T : class, new()
 {
     foreach (string str in IDString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
     {
         objBizBase.DeleteCache <D, T, Key>(str);
     }
 }
Beispiel #3
0
 private static string GetDependencyKey <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey = "") where D : DalBase <T, Key> where T : class, new()
 {
     if (string.IsNullOrWhiteSpace(dependencyKey))
     {
         dependencyKey = "Dependency_" + objBizBase.Dal.TableName.ToLower();
     }
     return(dependencyKey);
 }
Beispiel #4
0
        public static IList <T> GetPageListFieldsCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string condition, MySqlParameter[] parms, int pageSize, int pageIndex, string fields, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
        {
            dependencyKey = objBizBase.GetDependencyKey <D, T, Key>(dependencyKey);
            string cacheKey = string.Concat(new object[] { objBizBase.Dal.TableName.ToLower(), "PageList", GetCondtiionParam(condition, parms), sortExpression, pageSize, pageIndex, string.IsNullOrWhiteSpace(fields) ? "" : fields }).Replace(" ", "").ToLower();

            if (isCache)
            {
                IList <T> dependencyCache = cacheKey.GetDependencyCache <IList <T> >(dependencyKey);
                if (dependencyCache == null)
                {
                    dependencyCache = objBizBase.GetPageListFields(condition, parms, sortExpression, pageSize, pageIndex, fields);
                    dependencyCache.SetDependencyCache(dependencyKey, cacheKey, expiry);
                }
                return(dependencyCache);
            }
            DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, cacheKey));
            return(objBizBase.GetPageListFields(condition, parms, sortExpression, pageSize, pageIndex, fields));
        }
Beispiel #5
0
        public static IList <T> GetListCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string condition, MySqlParameter[] parms, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
        {
            dependencyKey = objBizBase.GetDependencyKey <D, T, Key>(dependencyKey);
            string cacheKey = (objBizBase.Dal.TableName.ToLower() + "List" + GetCondtiionParam(condition, parms) + sortExpression).Replace(" ", "").ToLower();

            if (isCache)
            {
                IList <T> dependencyCache = cacheKey.GetDependencyCache <IList <T> >(dependencyKey);
                if (dependencyCache == null)
                {
                    dependencyCache = objBizBase.GetList(condition, parms, sortExpression);
                    dependencyCache.SetDependencyCache(dependencyKey, cacheKey, expiry);
                }
                return(dependencyCache);
            }
            DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, cacheKey));
            return(objBizBase.GetList(condition, parms, sortExpression));
        }
Beispiel #6
0
        public static T GetRecordConditionCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, bool isCache, TimeSpan expiry, string idKey, string condition, MySqlParameter[] parms, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
        {
            T      cacheMemcached;
            string cacheKey = "";

            if (string.IsNullOrWhiteSpace(idKey))
            {
                string dependencyKey = objBizBase.GetDependencyKey <D, T, Key>("");
                cacheKey = (objBizBase.Dal.TableName.ToLower() + "_IDKey_" + GetCondtiionParam(condition, parms) + sortExpression).Replace(" ", "").ToLower();
                if (!isCache)
                {
                    DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, cacheKey));
                    return(objBizBase.GetRecord(condition, parms, sortExpression));
                }
                cacheMemcached = cacheKey.GetDependencyCache <T>(dependencyKey);
                if (cacheMemcached == null)
                {
                    cacheMemcached = objBizBase.GetRecord(condition, parms, sortExpression);
                    if (cacheMemcached == null)
                    {
                        return(cacheMemcached);
                    }
                    cacheMemcached.SetDependencyCache(dependencyKey, cacheKey, expiry);
                }
                return(cacheMemcached);
            }
            cacheKey = string.Format(objBizBase.Dal.TableName.ToLower() + "_" + idKey.ToLower(), new object[0]);
            if (!isCache)
            {
                cacheKey.DeleteCacheMemcached();
                return(objBizBase.GetRecord(condition, parms, sortExpression));
            }
            cacheMemcached = cacheKey.GetCacheMemcached <T>();
            if (cacheMemcached == null)
            {
                cacheMemcached = objBizBase.GetRecord(condition, parms, sortExpression);
                if (cacheMemcached == null)
                {
                    return(cacheMemcached);
                }
                cacheMemcached.SetCacheMemcached(cacheKey, expiry);
            }
            return(cacheMemcached);
        }
Beispiel #7
0
        public static DataSet GetDataSetViewLimitCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string condition, MySqlParameter[] parms, string sortExpression, int offset, int limit, string fields = "*") where D : DalBase <T, Key> where T : class, new()
        {
            dependencyKey = objBizBase.GetDependencyKey <D, T, Key>(dependencyKey);
            DataSet dependencyCache = null;
            string  cacheKey        = string.Concat(new object[] { objBizBase.Dal.TableViewName.ToLower(), "DataSetLimit", GetCondtiionParam(condition, parms), sortExpression, offset, limit, fields }).Replace(" ", "").ToLower();

            if (isCache)
            {
                dependencyCache = cacheKey.GetDependencyCache <DataSet>(dependencyKey);
                if (dependencyCache == null)
                {
                    dependencyCache = objBizBase.GetDataSetViewLimit(condition, parms, sortExpression, offset, limit, fields);
                    dependencyCache.SetDependencyCache(dependencyKey, cacheKey, expiry);
                }
                return(dependencyCache);
            }
            DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, cacheKey));
            return(objBizBase.GetDataSetViewLimit(condition, parms, sortExpression, offset, limit, fields));
        }
Beispiel #8
0
        public static object GetScalarCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string fieldName, string condition, MySqlParameter[] parms) where D : DalBase <T, Key> where T : class, new()
        {
            dependencyKey = objBizBase.GetDependencyKey <D, T, Key>(dependencyKey);
            object dependencyCache = null;
            string cacheKey        = (objBizBase.Dal.TableName.ToLower() + "Scalar" + GetCondtiionParam(condition, parms) + fieldName).Replace(" ", "").ToLower();

            if (isCache)
            {
                dependencyCache = cacheKey.GetDependencyCache <object>(dependencyKey);
                if (dependencyCache == null)
                {
                    dependencyCache = objBizBase.GetScalar(fieldName, condition, parms);
                    dependencyCache.SetDependencyCache(dependencyKey, cacheKey, expiry);
                }
                return(dependencyCache);
            }
            DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, cacheKey));
            return(objBizBase.GetScalar(fieldName, condition, parms));
        }
Beispiel #9
0
        public static DataSet GetDataSetTextCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string commandText, params MySqlParameter[] parms) where D : DalBase <T, Key> where T : class, new()
        {
            dependencyKey = objBizBase.GetDependencyKey <D, T, Key>(dependencyKey);
            DataSet dependencyCache = null;
            string  cacheKey        = (objBizBase.Dal.TableName.ToLower() + "DataSet" + GetCondtiionParam(commandText, parms)).Replace(" ", "").ToLower();

            if (isCache)
            {
                dependencyCache = cacheKey.GetDependencyCache <DataSet>(dependencyKey);
                if (dependencyCache == null)
                {
                    dependencyCache = objBizBase.Dal.ExecuteDataSet(commandText, parms);
                    dependencyCache.SetDependencyCache(dependencyKey, cacheKey, expiry);
                }
                return(dependencyCache);
            }
            DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, cacheKey));
            return(objBizBase.Dal.ExecuteDataSet(commandText, parms));
        }
Beispiel #10
0
        public static T GetRecordCacheGuid <D, T, Key>(this BizBase <D, T, Key> objBizBase, string guid, string guidFileName, TimeSpan timeSpan, bool isCache = true) where D : DalBase <T, Key> where T : class, new()
        {
            string cacheKey = string.Format(objBizBase.Dal.TableName.ToLower() + "_" + guid.ToLower(), new object[0]);

            if (!isCache)
            {
                cacheKey.DeleteCacheMemcached();
                return(objBizBase.GetRecord(guidFileName + "=?Guid", "Guid".CreateSqlParameter(new object[] { guid }), ""));
            }
            T cacheMemcached = cacheKey.GetCacheMemcached <T>();

            if (cacheMemcached == null)
            {
                cacheMemcached = objBizBase.GetRecord(guidFileName + "=?Guid", "Guid".CreateSqlParameter(new object[] { guid }), "");
                if (cacheMemcached == null)
                {
                    return(cacheMemcached);
                }
                cacheMemcached.SetCacheMemcached(cacheKey, timeSpan);
            }
            return(cacheMemcached);
        }
Beispiel #11
0
        public static DataSet GetPageViewCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string condition, MySqlParameter[] parms, string sortExpression, int pageSize, int pageIndex, out int recordCount, string fields = "*") where D : DalBase <T, Key> where T : class, new()
        {
            dependencyKey = objBizBase.GetDependencyKey <D, T, Key>(dependencyKey);
            string cacheKey = string.Concat(new object[] { objBizBase.Dal.TableViewName.ToLower(), "Page", GetCondtiionParam(condition, parms), sortExpression, pageSize, pageIndex, fields }).Replace(" ", "").ToLower();

            if (isCache)
            {
                PageCache dependencyCache = cacheKey.GetDependencyCache <PageCache>(dependencyKey);
                if (dependencyCache != null)
                {
                    recordCount = dependencyCache.RecordCount;
                    return(dependencyCache.Data);
                }
                DataSet set = objBizBase.GetPageView(condition, parms, sortExpression, pageSize, pageIndex, out recordCount, fields);
                new PageCache {
                    RecordCount = recordCount, Data = set
                }.SetDependencyCache(dependencyKey, cacheKey, expiry);
                return(set);
            }
            DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, cacheKey));
            return(objBizBase.GetPageView(condition, parms, sortExpression, pageSize, pageIndex, out recordCount, fields));
        }
Beispiel #12
0
        public static IList <T> GetPageListCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string condition, MySqlParameter[] parms, int pageSize, int pageIndex, out int recordCount, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
        {
            dependencyKey = objBizBase.GetDependencyKey <D, T, Key>(dependencyKey);
            string cacheKey = string.Concat(new object[] { objBizBase.Dal.TableName.ToLower(), "PageListCount", GetCondtiionParam(condition, parms), sortExpression, pageSize, pageIndex }).Replace(" ", "").ToLower();

            if (isCache)
            {
                PageCache <T> dependencyCache = cacheKey.GetDependencyCache <PageCache <T> >(dependencyKey);
                if (dependencyCache != null)
                {
                    recordCount = dependencyCache.RecordCount;
                    return(dependencyCache.Data);
                }
                dependencyCache = new PageCache <T> {
                    Data        = objBizBase.GetPageList(condition, parms, sortExpression, pageSize, pageIndex, out recordCount),
                    RecordCount = recordCount
                };
                dependencyCache.SetDependencyCache(dependencyKey, cacheKey, expiry);
                return(dependencyCache.Data);
            }
            DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, cacheKey));
            return(objBizBase.GetPageList(condition, parms, sortExpression, pageSize, pageIndex, out recordCount));
        }
Beispiel #13
0
        public static DataSet GetPageViewCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, string condition, MySqlParameter[] parms, string sortExpression, int pageSize, int pageIndex, string fields = "*") where D : DalBase <T, Key> where T : class, new()
        {
            int recordCount = 0;

            return(objBizBase.GetPageViewCache <D, T, Key>(dependencyKey, isCache, condition, parms, sortExpression, pageSize, pageIndex, out recordCount, fields));
        }
Beispiel #14
0
        public static T GetRecordCacheGuid <D, T, Key>(this BizBase <D, T, Key> objBizBase, string guid, string guidFileName, bool isCache = true) where D : DalBase <T, Key> where T : class, new()
        {
            TimeSpan timeSpan = new TimeSpan(0, ConfigHelper.GetIntValue("RecordCacheMinutes", 60), 0);

            return(objBizBase.GetRecordCacheGuid <D, T, Key>(guid, guidFileName, timeSpan, isCache));
        }
Beispiel #15
0
 public static bool DeleteCacheKey <D, T, Key>(this BizBase <D, T, Key> objBizBase, string cacheKey) where D : DalBase <T, Key> where T : class, new()
 {
     return(cacheKey.DeleteCacheMemcached());
 }
Beispiel #16
0
 public static T GetRecordCacheGuid <D, T, Key>(this BizBase <D, T, Key> objBizBase, string guid, bool isCache = true) where D : DalBase <T, Key> where T : class, new()
 {
     return(objBizBase.GetRecordCacheGuid <D, T, Key>(guid, "Guid", isCache));
 }
Beispiel #17
0
 public static DataSet GetDataSetViewLimitCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string condition, string sortExpression, int offset, int limit, string fields = "*") where D : DalBase <T, Key> where T : class, new()
 {
     return(objBizBase.GetDataSetViewLimitCache <D, T, Key>(dependencyKey, isCache, expiry, condition, null, sortExpression, offset, limit, fields));
 }
Beispiel #18
0
 public static bool DeleteCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string tableName, string key) where D : DalBase <T, Key> where T : class, new()
 {
     return(string.Format(tableName.ToLower() + "_" + key.ToLower(), new object[0]).DeleteCacheMemcached());
 }
Beispiel #19
0
 public static bool DeleteDependencyKey <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey = "") where D : DalBase <T, Key> where T : class, new()
 {
     return(objBizBase.GetDependencyKey <D, T, Key>(dependencyKey).DeleteCacheMemcached());
 }
Beispiel #20
0
        public static T GetRecordConditionCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, bool isCache, string idKey, string condition, MySqlParameter[] parms, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
        {
            TimeSpan expiry = new TimeSpan(0, ConfigHelper.GetIntValue("PageCacheMinutes", 60), 0);

            return(objBizBase.GetRecordConditionCache <D, T, Key>(isCache, expiry, idKey, condition, parms, sortExpression));
        }
Beispiel #21
0
 public static IList <T> GetPageListCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string condition, int pageSize, int pageIndex, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
 {
     return(objBizBase.GetPageListCache <D, T, Key>(dependencyKey, isCache, expiry, condition, null, pageSize, pageIndex, sortExpression));
 }
Beispiel #22
0
        public static IList <T> GetPageListFieldsCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, string condition, MySqlParameter[] parms, int pageSize, int pageIndex, out int recordCount, string fields, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
        {
            TimeSpan expiry = new TimeSpan(0, ConfigHelper.GetIntValue("PageCacheMinutes", 60), 0);

            return(objBizBase.GetPageListFieldsCache <D, T, Key>(dependencyKey, isCache, expiry, condition, parms, pageSize, pageIndex, out recordCount, fields, sortExpression));
        }
Beispiel #23
0
 public static IList <T> GetPageListFieldsCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, string condition, int pageSize, int pageIndex, out int recordCount, string fields, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
 {
     return(objBizBase.GetPageListFieldsCache <D, T, Key>(dependencyKey, isCache, condition, null, pageSize, pageIndex, out recordCount, fields, sortExpression));
 }
Beispiel #24
0
 public static bool DeleteCacheID <D, T, Key>(this BizBase <D, T, Key> objBizBase, Key ID) where D : DalBase <T, Key> where T : class, new()
 {
     return(string.Format(objBizBase.Dal.TableName.ToLower() + "_" + ID.ToString(), new object[0]).DeleteCacheMemcached());
 }
Beispiel #25
0
 public static T GetRecordConditionCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, bool isCache, TimeSpan expiry, string idKey, string condition, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
 {
     return(objBizBase.GetRecordConditionCache <D, T, Key>(isCache, expiry, idKey, condition, null, sortExpression));
 }
Beispiel #26
0
 public static DataSet GetPageViewCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, TimeSpan expiry, string condition, string sortExpression, int pageSize, int pageIndex, out int recordCount, string fields = "*") where D : DalBase <T, Key> where T : class, new()
 {
     return(objBizBase.GetPageViewCache <D, T, Key>(dependencyKey, isCache, expiry, condition, null, sortExpression, pageSize, pageIndex, out recordCount, fields));
 }
Beispiel #27
0
        public static DataSet GetPageViewCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, string condition, string sortExpression, int pageSize, int pageIndex, out int recordCount, string fields = "*") where D : DalBase <T, Key> where T : class, new()
        {
            TimeSpan expiry = new TimeSpan(0, ConfigHelper.GetIntValue("PageCacheMinutes", 60), 0);

            return(objBizBase.GetPageViewCache <D, T, Key>(dependencyKey, isCache, expiry, condition, sortExpression, pageSize, pageIndex, out recordCount, fields));
        }
Beispiel #28
0
        public static IList <T> GetListCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, string condition, string sortExpression = "") where D : DalBase <T, Key> where T : class, new()
        {
            TimeSpan expiry = new TimeSpan(0, ConfigHelper.GetIntValue("PageCacheMinutes", 60), 0);

            return(objBizBase.GetListCache <D, T, Key>(dependencyKey, isCache, expiry, condition, sortExpression));
        }
Beispiel #29
0
        public static DataSet GetDataSetCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, string condition, MySqlParameter[] parms, string sortExpression, string fields = "*") where D : DalBase <T, Key> where T : class, new()
        {
            TimeSpan expiry = new TimeSpan(0, ConfigHelper.GetIntValue("PageCacheMinutes", 60), 0);

            return(objBizBase.GetDataSetCache <D, T, Key>(dependencyKey, isCache, expiry, condition, parms, sortExpression, fields));
        }
Beispiel #30
0
        public static DataSet GetDataSetTextCache <D, T, Key>(this BizBase <D, T, Key> objBizBase, string dependencyKey, bool isCache, string commandText, params MySqlParameter[] parms) where D : DalBase <T, Key> where T : class, new()
        {
            TimeSpan expiry = new TimeSpan(0, ConfigHelper.GetIntValue("PageCacheMinutes", 60), 0);

            return(objBizBase.GetDataSetTextCache <D, T, Key>(dependencyKey, isCache, expiry, commandText, parms));
        }