Exemplo n.º 1
0
        public void LoginOut(string userId, string deviceType)
        {
            var temp = GetUserById(userId, null);

            if (temp != null)
            {
                var key = UserHelper.CreateCacheKey(temp);
                if (cacheUsers.Contains(key))
                {
                    cacheUsers.Remove(key);
                }
            }
        }
Exemplo n.º 2
0
        public bool AddToCache(User user, string deviceType)
        {
            var temp = GetUserById(user.Id, deviceType);

            if (temp == null)
            {
                user.Token = Guid.NewGuid().ToString().EncryptByMD5();
                CacheItemPolicy p = new CacheItemPolicy {
                    Priority = CacheItemPriority.Default
                };
                //p.AbsoluteExpiration = new DateTimeOffset(DateTime.Now.AddDays(5));
                cacheUsers.Add(new CacheItem(UserHelper.CreateCacheKey(user), user, REGIN_NAME), p);
            }
            else
            {
                user.Token = temp.Token;
            }
            return(true);
        }