Ejemplo n.º 1
0
        public static IEnumerable <T> QueryPageCache <T>(this SolrQuery <T> objSolrQuery, string dependencyKey, bool isCache, TimeSpan expiry, string fields, Expression <Func <T, bool> > predicate, string qf, string highlightFields, int pageSize, int pageIndex, string sortExpression, out long recordCount, string bf = "") where T : class, new()
        {
            dependencyKey = objSolrQuery.GetDependencyKey(dependencyKey);
            string text  = objSolrQuery.Condiition(predicate);
            string text2 = string.Concat(new object[]
            {
                objSolrQuery.TableName.ToLower(),
                "SolrPageList",
                fields,
                text,
                qf,
                highlightFields,
                pageSize,
                pageIndex,
                sortExpression,
                bf
            });

            text2 = text2.Replace(" ", "").ToLower();
            IEnumerable <T> result;

            if (isCache)
            {
                PageSolrCache <T> dependencyCache = MemcacheCacheHelper.GetDependencyCache <PageSolrCache <T> >(text2, dependencyKey);
                if (dependencyCache != null)
                {
                    recordCount = dependencyCache.RecordCount;
                    result      = dependencyCache.Data;
                }
                else
                {
                    IEnumerable <T> enumerable = objSolrQuery.QueryPage(fields, text, qf, highlightFields, pageSize, pageIndex, sortExpression, out recordCount, bf);
                    MemcacheCacheHelper.SetDependencyCache(new PageSolrCache <T>
                    {
                        RecordCount = recordCount,
                        Data        = enumerable
                    }, dependencyKey, text2, expiry);
                    result = enumerable;
                }
            }
            else
            {
                SolrCacheBindHelper.DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, text2));
                result = objSolrQuery.QueryPage(fields, text, qf, highlightFields, pageSize, pageIndex, sortExpression, out recordCount, bf);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static DataSet QueryDataSetLimitCache <T>(this SolrQuery <T> objSolrQuery, string dependencyKey, bool isCache, TimeSpan expiry, string fields, string condition, string qf, string highlightFields, int offset, int limit, string sortExpression, out long recordCount, string bf = "") where T : class, new()
        {
            dependencyKey = objSolrQuery.GetDependencyKey(dependencyKey);
            string text = string.Concat(new object[]
            {
                objSolrQuery.TableName.ToLower(),
                "SolrDataSetLimit",
                fields,
                condition,
                qf,
                highlightFields,
                offset,
                limit,
                sortExpression,
                bf
            });

            text = text.Replace(" ", "").ToLower();
            DataSet result;

            if (isCache)
            {
                PageSolrCache dependencyCache = MemcacheCacheHelper.GetDependencyCache <PageSolrCache>(text, dependencyKey);
                if (dependencyCache != null)
                {
                    recordCount = dependencyCache.RecordCount;
                    result      = dependencyCache.Data;
                }
                else
                {
                    DataSet dataSet = objSolrQuery.QueryDataSetLimit(fields, condition, qf, highlightFields, offset, limit, sortExpression, out recordCount, bf);
                    MemcacheCacheHelper.SetDependencyCache(new PageSolrCache
                    {
                        RecordCount = recordCount,
                        Data        = dataSet
                    }, dependencyKey, text, expiry);
                    result = dataSet;
                }
            }
            else
            {
                SolrCacheBindHelper.DeleteCacheKey(MemcacheCacheHelper.CreateDependencyCacheKey(dependencyKey, text));
                result = objSolrQuery.QueryDataSetLimit(fields, condition, qf, highlightFields, offset, limit, sortExpression, out recordCount, bf);
            }
            return(result);
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
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));
        }