From e00f1a0410a3f57dea4a0cae1376a5d73609d75b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 7 Apr 2014 15:01:06 +0300 Subject: [PATCH] Allow invalidating the users cache --- .../UserAccounts/LocalUserAccountServiceConnector.cs | 10 +++++++++- .../UserAccounts/UserAccountCache.cs | 7 ++++++- .../SimianGrid/SimianUserAccountServiceConnector.cs | 5 +++++ .../UserAccounts/UserAccountServicesConnector.cs | 4 ++++ OpenSim/Services/HypergridService/UserAccountCache.cs | 7 ++++++- OpenSim/Services/Interfaces/IUserAccountService.cs | 2 ++ .../Services/UserAccountService/UserAccountService.cs | 4 ++++ 7 files changed, 36 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 529bfd7289..6d4ac39649 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -190,7 +190,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts // public bool StoreUserAccount(UserAccount data) { - return UserAccountService.StoreUserAccount(data); + bool ret = UserAccountService.StoreUserAccount(data); + if (ret) + m_Cache.Cache(data.PrincipalID, data); + return ret; + } + + public void InvalidateCache(UUID userID) + { + m_Cache.Invalidate(userID); } #endregion diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index ddef75f616..ed52e4879e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -61,6 +61,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); } + public void Invalidate(UUID userID) + { + m_UUIDCache.Remove(userID); + } + public UserAccount Get(UUID userID, out bool inCache) { UserAccount account = null; diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index 7e36c69cc7..698c4c0872 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs @@ -191,6 +191,11 @@ namespace OpenSim.Services.Connectors.SimianGrid return accounts; } + public void InvalidateCache(UUID userID) + { + m_accountCache.Remove(userID); + } + public bool StoreUserAccount(UserAccount data) { // m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs index 97d94585d9..8110fe56e1 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs @@ -187,6 +187,10 @@ namespace OpenSim.Services.Connectors return accounts; } + public void InvalidateCache(UUID userID) + { + } + public virtual bool StoreUserAccount(UserAccount data) { Dictionary sendData = new Dictionary(); diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs index 65f9dd5d31..fa7dd0be47 100644 --- a/OpenSim/Services/HypergridService/UserAccountCache.cs +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Reflection; @@ -95,6 +95,11 @@ namespace OpenSim.Services.HypergridService return null; } + public void InvalidateCache(UUID userID) + { + m_UUIDCache.Remove(userID); + } + public bool StoreUserAccount(UserAccount data) { return false; diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs index 1b859805a6..2f7702c98a 100644 --- a/OpenSim/Services/Interfaces/IUserAccountService.cs +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs @@ -189,5 +189,7 @@ namespace OpenSim.Services.Interfaces /// /// bool StoreUserAccount(UserAccount data); + + void InvalidateCache(UUID userID); } } diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 1852e4fe1f..40d8095904 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -256,6 +256,10 @@ namespace OpenSim.Services.UserAccountService return MakeUserAccount(d[0]); } + public void InvalidateCache(UUID userID) + { + } + public bool StoreUserAccount(UserAccount data) { // m_log.DebugFormat(