예제 #1
0
        /// <summary>
        /// 移除Session
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public long Remove(string key)
        {
            var rs = Redisc.Delete(key);

            CookieHelp.ClearCookieValByKey(key);
            return(rs);
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key">webcookie标识</param>
 /// <param name="sourceid">加密的sourceid获取redis缓存数据</param>
 /// <param name="value"></param>
 public bool SetSession(string key, string sourceid, T value)
 {
     if (string.IsNullOrWhiteSpace(key))
     {
         throw new Exception("Key is Null or Epmty");
     }
     CookieHelp.SetCookies(key, sourceid);
     return(Redisc.SetValue(key, value, TimeSpan.FromSeconds(secondsTimeOut)));
 }
예제 #3
0
        public T this[string key, string sourceid]
        {
            get
            {
                string webCookie = CookieHelp.GetCookieValByKey(key);
                if (webCookie == "")
                {
                    return(default(T));
                }

                //距离过期时间还有多少秒
                var l = Redisc.TTL(key);
                if (l >= 0)
                {
                    Redisc.Expire(key, secondsTimeOut);
                }
                return(Redisc.GetValue <T>(key));
            }
            set
            {
                SetSession(key, sourceid, value);
            }
        }