示例#1
0
        public override void AddUserToCache(IUser user)
        {
            if (user != null && MinutesInCache > 0)
            {
                lock (padlock) {
                    if (cachedUsers.Contains(user))
                    {
                        RemoveUserFromCache(user);
                    }

                    // Truncate cache if it has grown out of size.
                    if (MaxUsersInCache != 0 && cachedUsers.Count >= MaxUsersInCache)
                    {
                        TruncateCache();
                    }

                    user.MakeReadOnly();

                    var cacheMapId = new CacheMapId(user.UserName, user.Domain);
                    var cachedUser = new CachedUser(user);
                    cachedMap.Add(cacheMapId, cachedUser);
                    cachedUsers.Add(user);
                }
            }
        }
示例#2
0
		public override void AddUserToCache(IUser user) {
			if(user != null && MinutesInCache > 0) {
				lock(padlock) {
					if(cachedUsers.Contains(user)) {
						RemoveUserFromCache(user);
					}

					// Truncate cache if it has grown out of size.
					if(MaxUsersInCache != 0 && cachedUsers.Count >= MaxUsersInCache) {
						TruncateCache();
					}

					user.MakeReadOnly();

					var cacheMapId = new CacheMapId(user.UserName, user.Domain);
					var cachedUser = new CachedUser(user);
					cachedMap.Add(cacheMapId, cachedUser);
					cachedUsers.Add(user);
				}
			}
		}