Exemple #1
0
        /// <summary>
        /// 设置Session到Redis
        /// </summary>
        /// <param name="key">sessionID=cookieID即用户ID </param>
        /// <param name="value">自定义类型</param>
        public static bool Set <T>(string key, T value)
        {
            bool b = RedisString.Set <T>(key, value, new TimeSpan(0, RedisManager.TimeOut, 0));

//            HeShang365.Log.Logger.Info("设置键值1:", key + "," + value + "," + DateTime.Now.ToString());
            return(b);
        }
Exemple #2
0
 // <summary>
 //获取Session值
 //</summary>
 //<param name="key">sessionID = cookieID即用户ID</param>
 //<returns>返回SessionID对应的自定义对象值</returns>
 public static T Get <T>(string key)
 {
     if (string.IsNullOrWhiteSpace(key))
     {
         throw new Exception("Key is Null or Epmty");
     }
     return(RedisString.GetValue <T>(key));
 }
Exemple #3
0
        /// <summary>
        /// 获取Session值
        /// </summary>
        /// <param name="key">sessionID=cookieID即用户ID</param>
        /// <returns>返回SessionID对应的值</returns>
        public static string Get(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new Exception("Key is Null or Epmty");
            }
            string keyValues = RedisString.Get(key);

            // bool b = RedisString.SetExpire(key,new TimeSpan(0, RedisManager.TimeOut, 0));
            //  bool b1 = redisString.Set(SessionId + key, value.ToString(), new TimeSpan(0, RedisManager.TimeOut, 0));
//            HeShang365.Log.Logger.Info("获取键值1:", key + "," + keyValues + "," + DateTime.Now.ToString());
            return(keyValues);
        }