public bool CheckLogin() { var cache = new MemoryCacheStruct <ChatUser>(); ChatUser chatUser = cache.Find(t => t.UserName == PassportID); if (chatUser != null) { UserID = chatUser.UserId.ToString(); return(true); } //not user create it. chatUser = new ChatUser() { UserId = (int)RedisConnectionPool.GetNextNo(typeof(ChatUser).FullName), UserName = PassportID, AccessTime = DateTime.Now }; if (cache.TryAdd(chatUser.UserId.ToString(), chatUser)) { UserID = chatUser.UserId.ToString(); return(true); } return(false); }
/// <summary> /// 获取实体的下个编号 /// </summary> /// <returns></returns> public long GetNextNo() { string key = string.Format(PrimaryKeyFormat, typeof(T).Name); return(RedisConnectionPool.GetNextNo(key)); }
/// <summary> /// 获取实体的下个编号 /// </summary> /// <returns></returns> public long GetNextNo() { string key = "EntityPrimaryKey_" + typeof(T).Name; return(RedisConnectionPool.GetNextNo(key)); }
/// <summary> /// 获取实体的下个编号 /// </summary> /// <returns></returns> public long GetNextNo(bool isLock = false) { string key = string.Format(PrimaryKeyFormat, typeof(T).Name); return(RedisConnectionPool.GetNextNo(key, 1, isLock)); }