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

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

            return(RedisConnectionPool.GetNextNo(key));
        }
Ejemplo n.º 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));
        }