From b43f36abf168a0cce7e71178e3d4766a717c7d60 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 18 Nov 2016 15:16:11 +0000 Subject: [PATCH] add expire time for aliens --- .../UserAccounts/UserAccountCache.cs | 33 +++++++++++++++---- .../Interfaces/IUserAccountCacheModule.cs | 2 ++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index 6c1cc525b2..2afd74e36e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs @@ -36,6 +36,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { public class UserAccountCache : IUserAccountCacheModule { + private const double CACHE_ALIEN_EXPIRATION_SECONDS = 172800; // 48 hours private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour! private const double CACHE_NULL_EXPIRATION_SECONDS = 600; // 10minutes @@ -60,21 +61,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { if (account == null) m_UUIDCache.AddOrUpdate(userID, null, CACHE_NULL_EXPIRATION_SECONDS); - else + else if(account.LocalToGrid) { m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, CACHE_EXPIRATION_SECONDS); } - + else + { + m_UUIDCache.AddOrUpdate(userID, account, CACHE_ALIEN_EXPIRATION_SECONDS); + m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, CACHE_ALIEN_EXPIRATION_SECONDS); + } //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); } } - public void Invalidate(UUID userID) - { - lock(accessLock) - m_UUIDCache.Remove(userID); - } public UserAccount Get(UUID userID, out bool inCache) { @@ -114,6 +114,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts return null; } + public void Invalidate(UUID userID) + { + m_UUIDCache.Remove(userID); + } + + public void Remove(UUID id) + { + lock(accessLock) + { + if (!m_UUIDCache.Contains(id)) + return; + + UserAccount account = null; + if (m_UUIDCache.TryGetValue(id, out account) && account != null) + m_NameCache.Remove(account.Name); + m_UUIDCache.Remove(id); + } + } + public void Remove(string name) { lock(accessLock) diff --git a/OpenSim/Region/Framework/Interfaces/IUserAccountCacheModule.cs b/OpenSim/Region/Framework/Interfaces/IUserAccountCacheModule.cs index ed269896a9..027a7e2e5a 100644 --- a/OpenSim/Region/Framework/Interfaces/IUserAccountCacheModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IUserAccountCacheModule.cs @@ -26,8 +26,10 @@ */ using OpenSim.Region.Framework.Scenes; +using OpenMetaverse; public interface IUserAccountCacheModule { void Remove(string name); + void Remove(UUID id); }