From f86c438653fc3c8356a8f0c43a055b1928183f02 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 29 Nov 2010 08:43:33 -0800 Subject: Preservation of creator information now also working in IARs. Cleaned up usage help. Moved Osp around, deleted unnecessary OspInventoryWrapperPlugin, added manipulation of SOP's xml representation in a generic ExternalRepresentationUtils function. --- .../Services/HypergridService/UserAccountCache.cs | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 OpenSim/Services/HypergridService/UserAccountCache.cs (limited to 'OpenSim/Services/HypergridService/UserAccountCache.cs') diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs new file mode 100644 index 0000000..3e9aea1 --- /dev/null +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +using log4net; +using OpenMetaverse; + +using OpenSim.Services.Interfaces; + +namespace OpenSim.Services.HypergridService +{ + public class UserAccountCache : IUserAccountService + { + private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! + + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + private ExpiringCache m_UUIDCache; + + private IUserAccountService m_UserAccountService; + + private static UserAccountCache m_Singleton; + + public static UserAccountCache CreateUserAccountCache(IUserAccountService u) + { + if (m_Singleton == null) + m_Singleton = new UserAccountCache(u); + + return m_Singleton; + } + + private UserAccountCache(IUserAccountService u) + { + m_UUIDCache = new ExpiringCache(); + m_UserAccountService = u; + } + + public void Cache(UUID userID, UserAccount account) + { + // Cache even null accounts + m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); + + //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); + } + + public UserAccount Get(UUID userID, out bool inCache) + { + UserAccount account = null; + inCache = false; + if (m_UUIDCache.TryGetValue(userID, out account)) + { + //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); + inCache = true; + return account; + } + + return null; + } + + public UserAccount GetUser(string id) + { + UUID uuid = UUID.Zero; + UUID.TryParse(id, out uuid); + bool inCache = false; + UserAccount account = Get(uuid, out inCache); + if (!inCache) + { + account = m_UserAccountService.GetUserAccount(UUID.Zero, uuid); + Cache(uuid, account); + } + + return account; + } + + #region IUserAccountService + public UserAccount GetUserAccount(UUID scopeID, UUID userID) + { + return GetUser(userID.ToString()); + } + + public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) + { + return null; + } + + public UserAccount GetUserAccount(UUID scopeID, string Email) + { + return null; + } + + public List GetUserAccounts(UUID scopeID, string query) + { + return null; + } + + public bool StoreUserAccount(UserAccount data) + { + return false; + } + #endregion + + } + +} -- cgit v1.1 From 3083c517a01b4265434f9286aa1c95b2b513549b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 18 Jan 2011 00:29:10 +0000 Subject: minor: resolve some mono compiler warnings --- OpenSim/Services/HypergridService/UserAccountCache.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/HypergridService/UserAccountCache.cs') diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs index 3e9aea1..65f9dd5 100644 --- a/OpenSim/Services/HypergridService/UserAccountCache.cs +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs @@ -13,9 +13,10 @@ namespace OpenSim.Services.HypergridService { private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); + private ExpiringCache m_UUIDCache; private IUserAccountService m_UserAccountService; -- cgit v1.1 From e00f1a0410a3f57dea4a0cae1376a5d73609d75b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 7 Apr 2014 15:01:06 +0300 Subject: Allow invalidating the users cache --- OpenSim/Services/HypergridService/UserAccountCache.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/HypergridService/UserAccountCache.cs') diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs index 65f9dd5..fa7dd0b 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; -- cgit v1.1