/// <summary> /// 保存信息 /// </summary> public void SaveInfo() { string key = txtKey.TextTrim; if (txtID.Text.IsNull()) { MemcacheCacheHelper.DeleteCacheMemcached(key); } else { MemcacheCacheHelper.DeleteCacheMemcached(key.ToLower() + "_" + txtID.TextTrim.ToLower()); } MessageDialog("删除缓存成功"); }
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); }
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); }
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)); }
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)); }
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); }
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)); }
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)); }
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)); }
/// <summary> /// 工具栏操作 /// </summary> protected override void CurrentTool_ItemCommand(object sender, WTF.Controls.MyCommandEventArgs e) { switch (e.CommandName) { case "Save": SaveInfo(); break; case "GetCache": string key = txtKey.TextTrim; object cacheValue; if (txtID.Text.IsNull()) { cacheValue = MemcacheCacheHelper.GetCacheMemcached(key); } else { cacheValue = MemcacheCacheHelper.GetCacheMemcached(key.ToLower() + "_" + txtID.TextTrim.ToLower()); } if (cacheValue == null) { txtResult.Text = "null"; } else { txtResult.Text = cacheValue.JsonJsSerialize(); if (txtResult.Text == "null") { txtResult.Text = "有缓存值,后台无法格式化内容输出"; } } break; case "Back": Redirect("CacheKeyList.aspx?CacheSiteID=" + CacheSiteID); break; } }
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)); }
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)); }
public static bool DeleteDependencyKey <T>(this SolrQuery <T> objSolrQuery, string dependencyKey = "") where T : class, new() { return(MemcacheCacheHelper.DeleteCacheMemcached(objSolrQuery.GetDependencyKey(dependencyKey))); }
public static bool DeleteCacheKey <T>(this SolrQuery <T> objSolrQuery, string cacheKey) where T : class, new() { return(MemcacheCacheHelper.DeleteCacheMemcached(cacheKey)); }
private static bool DeleteCacheKey(string cacheKey) { return(MemcacheCacheHelper.DeleteCacheMemcached(cacheKey)); }