asp.net mvc 用Redis实现分布式集群共享Session(二)

2015-07-23 18:08:27 · 作者: · 浏览: 37
? if (timeout > 0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? secondsTimeOut = timeout;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Redis.Expire(key, secondsTimeOut);
? ? ? ? ? ? }
? ? ? ? ? ? return true;
? ? ? ? ? ?
? ? ? ? }
? ? ? ? ///
? ? ? ? /// 获取
? ? ? ? ///

? ? ? ? ///
? ? ? ? ///
? ? ? ? ///
? ? ? ? public T Get(string key)
? ? ? ? {
? ? ? ? ? ? return Redis.Get(key);
? ? ? ? }
? ? ? ? ///
? ? ? ? /// 删除
? ? ? ? ///

? ? ? ? ///
? ? ? ? ///
? ? ? ? public bool Remove(string key)
? ? ? ? {
? ? ? ? ? ? return Redis.Remove(key);
? ? ? ? }
? ? ? ? #endregion


? ? ? ? //释放资源
? ? ? ? public void Dispose()
? ? ? ? {
? ? ? ? ? ? if (Redis != null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Redis.Dispose();
? ? ? ? ? ? ? ? Redis = null;
? ? ? ? ? ? }
? ? ? ? ? ? GC.Collect();


? ? ? ? }
? ? }