예제 #1
0
        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);
        }
예제 #2
0
        /// <summary>
        /// 获取实体的下个编号
        /// </summary>
        /// <returns></returns>
        public long GetNextNo()
        {
            string key = string.Format(PrimaryKeyFormat, typeof(T).Name);

            return(RedisConnectionPool.GetNextNo(key));
        }
예제 #3
0
        /// <summary>
        /// 获取实体的下个编号
        /// </summary>
        /// <returns></returns>
        public long GetNextNo()
        {
            string key = "EntityPrimaryKey_" + typeof(T).Name;

            return(RedisConnectionPool.GetNextNo(key));
        }
예제 #4
0
        /// <summary>
        /// 获取实体的下个编号
        /// </summary>
        /// <returns></returns>
        public long GetNextNo(bool isLock = false)
        {
            string key = string.Format(PrimaryKeyFormat, typeof(T).Name);

            return(RedisConnectionPool.GetNextNo(key, 1, isLock));
        }