/// <summary> /// 向缓存中登记一个新的Token,将CustomerId作为唯一key /// </summary> /// <param name="property">对应的用户属性</param> /// <param name="EndTime">过期时限</param> /// <returns>返回0为成功,其它为错误值</returns> public int AddToken(string tokenKey, TokenCacheProperty property, DateTime EndTime) { bool bFlag = mc.AddObject(tokenKey, property, EndTime); if (bFlag) { return(0); } else { return((int)CodeEnum.ApplicationErr); } }
/// <summary> /// 以Token 更新 TokenCacheProperty 下的最后访问时间 /// 注:这里会同时更新该token的property,在性能上可能存在隐患。 /// </summary> /// <param name="tokenKey">CustomerToken</param> /// <param name="property">对应的用户属性</param> /// <param name="EndTime">过期时限</param>/// /// <returns></returns> public int RefreshAccessTime(string tokenKey, TokenCacheProperty property, DateTime EndTime) { bool bFlag = mc.UpdateObject(tokenKey, property, EndTime); if (bFlag) { return(0); } else { return((int)CodeEnum.ApplicationErr); } }
/// <summary> /// 返回当期在线所有用户 /// </summary> public IList <TokenCacheProperty> FindAll() { IList <TokenCacheProperty> tokenCachePropertyFlag = new List <TokenCacheProperty>(); try { //用于查找标记为 customer_ 的信息 string customerTag = "customer_"; Hashtable resultHashtable = mc.GetStats(customerTag); foreach (string key in resultHashtable.Keys) { TokenCacheProperty tcp = FindByCustomerToken(key); tokenCachePropertyFlag.Add(tcp); } } catch { return(null); } return(tokenCachePropertyFlag); }