protected void Page_Load(object sender, EventArgs e) { string fsid = Request["zheshiyige_FID"].ToString(); long delshu = 0; try { RedisClient RC = RedisClass.GetRedisClient(null); string hashid = "ZlistCache_" + fsid; delshu = RC.Del(hashid); } catch { Response.Write("缓存清理失败,无法访问缓存!"); return; } //返回下载地址和状态"" if (delshu > 0) { Response.Write("缓存清理完成,下次刷新将获得最新数据并重新建立缓存!"); } else { Response.Write("缓存不存在,无需清理!"); } }
private void gogo() { RedisClient newRC = RedisClass.GetRedisClient(null); lock (RedisClass.LockObj) { byte[] Buffer = newRC.Get("cc"); } }
/// <summary> /// 开始处理,尝试更新缓存 /// </summary> /// <param name="typeS">操作类型,包括“更新”、“插入”</param> /// <param name="P_cmd">原始带参数的sql语句</param> /// <param name="P_ht_in">原始传入的参数</param> /// <param name="tablename">被操作的表名</param> /// <param name="filed">被操作的字段和对应值</param> /// <param name="where">操作条件字段和对应值</param> /// <returns></returns> public string TryUpdateRedis(string typeS, string P_cmd, Hashtable P_ht_in, string tablename, Dictionary <string, string> filed, Dictionary <string, string> where) { //获得数据后,根据需要进行判断和处理。 注意。 字段名称一般不会有错误,但是对应值,不一定是期待的@dlyx这样的,也可能是“dj+1”这样的东西。 具体情况具体处理。 RedisClient RC = RedisClass.GetRedisClient(null); RC.Add("aaaaaaaaaaaa", "bbbbbbbbbbb"); return("ok"); }
private void btnResetRedisPKid_Click(object sender, EventArgs e) { I_Dblink I_DBL = (new DBFactory()).DbLinkSqlMain(""); Hashtable htInput = new Hashtable(); htInput.Add("@date", null); Hashtable htres = I_DBL.RunProc_CMD("[dbo].[AAA_getTableMaxNum_redis]", "tab", htInput); DataSet ds = new DataSet(); if ((bool)htres["return_float"]) { ds = (DataSet)htres["return_ds"]; } else { ds = null; } if (ds != null && ds.Tables.Contains("tab") && ds.Tables["tab"].Rows.Count > 0) { RedisClient RC = RedisClass.GetRedisClient("OnlyOpenOneCheckRedis"); string txt = "TableName MaxNum MaxId" + Environment.NewLine + "-------------------------------------" + Environment.NewLine; //-------计算有效期截止时间--------------- DateTime dateStart = DateTime.Now; //获取当月最后一天的时间 DateTime dateEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1); //获取当前时间与当月最后一天相差的秒数作为键值的生命周期 TimeSpan ts = dateEnd.Subtract(dateStart).Duration(); string seconds = ts.TotalSeconds.ToString("0"); using (IRedisTransaction IRT = RC.CreateTransaction()) {//使用事务提交所有重置键值的操作语句 foreach (DataRow dr in ds.Tables[0].Rows) { txt += dr["tname"].ToString() + " " + dr["maxnum"].ToString() + " " + dr["maxid"].ToString() + Environment.NewLine; string key = "str:TablePK:" + dr["tname"].ToString() + DateTime.Now.ToString("yyyyMM"); IRT.QueueCommand(r => r.Set(key, Convert.ToInt32(dr["maxid"].ToString()))); IRT.QueueCommand(r => r.ExpireEntryAt(key, dateEnd)); } IRT.Commit(); // 提交事务 } //将待处理的表信息显示在界面上 richTextBox1.Text = txt; } else { richTextBox1.Text = "没有需要处理的信息!"; } }
private void gogo() { RedisClient newRC = RedisClass.GetRedisClient(null); byte[] Buffer = newRC.Get("cc"); }