public void SetMemchche(string Key, object obj, string TableName, int Keyid, string Para, int seconds) { try { DateTime now = System.DateTime.Now; TextExecuteNonQuery("delete from Lebi_Memcache where CacheKey='" + Key + "'");//删除已有记录 MemcacheInstance.Set(Key, obj, now.AddSeconds(seconds)); if (MemcacheInstance != null) { if (Para.Length > 1000) { Para = Para.Substring(0, 1000); } StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Memcache]("); strSql.Append("CacheKey,TableName,Keyid,Para,Time_Add,Time_End,seconds)"); strSql.Append(" values ("); strSql.Append("@CacheKey,@TableName,@Keyid,@Para,@Time_Add,@Time_End,@seconds)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CacheKey", Key), new SqlParameter("@TableName", TableName), new SqlParameter("@Keyid", Keyid), new SqlParameter("@Para", Para), new SqlParameter("@Time_Add", now), new SqlParameter("@Time_End", now.AddSeconds(seconds)), new SqlParameter("@seconds", seconds) }; TextExecuteNonQuery(strSql.ToString(), parameters); } } catch { } }
public object GetMemchche(string Key) { return(MemcacheInstance.Get(Key)); }