diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs (renamed from OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs) | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index 76c4899..e430fc7 100644 --- a/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -24,51 +24,63 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | using System; | |
28 | using OpenMetaverse; | 28 | using System.Reflection; |
29 | using System.Collections.Generic; | ||
29 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
30 | using OpenSim.Framework.Communications; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenMetaverse; | ||
33 | using log4net; | ||
31 | 34 | ||
32 | namespace OpenSim.Grid.MessagingServer.Modules | 35 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts |
33 | { | 36 | { |
34 | public class UserDataBaseService : UserManagerBase | 37 | public class UserAccountCache |
35 | { | 38 | { |
36 | /// <summary> | 39 | //private static readonly ILog m_log = |
37 | /// Constructor. | 40 | // LogManager.GetLogger( |
38 | /// </summary> | 41 | // MethodBase.GetCurrentMethod().DeclaringType); |
39 | /// Passing null to parent because we never use any function that requires an interservice inventory call. | 42 | |
40 | public UserDataBaseService() | 43 | private ICnmCache<UUID, UserAccount> m_UUIDCache; |
41 | : base(null) | 44 | private Dictionary<string, UUID> m_NameCache; |
45 | |||
46 | public UserAccountCache() | ||
42 | { | 47 | { |
48 | // Warning: the size values are a bit fuzzy. What matters | ||
49 | // most for this cache is the count value (128 entries). | ||
50 | m_UUIDCache = CnmSynchronizedCache<UUID, UserAccount>.Synchronized(new CnmMemoryCache<UUID, UserAccount>( | ||
51 | 128, 128*512, TimeSpan.FromMinutes(30.0))); | ||
52 | m_NameCache = new Dictionary<string, UUID>(); // this one is unbound | ||
43 | } | 53 | } |
44 | 54 | ||
45 | public UserAgentData GetUserAgentData(UUID AgentID) | 55 | public void Cache(UserAccount account) |
46 | { | 56 | { |
47 | UserProfileData userProfile = GetUserProfile(AgentID); | 57 | m_UUIDCache.Set(account.PrincipalID, account, 512); |
58 | m_NameCache[account.Name] = account.PrincipalID; | ||
59 | |||
60 | //m_log.DebugFormat("[USER CACHE]: cached user {0} {1}", account.FirstName, account.LastName); | ||
61 | } | ||
48 | 62 | ||
49 | if (userProfile != null) | 63 | public UserAccount Get(UUID userID) |
64 | { | ||
65 | UserAccount account = null; | ||
66 | if (m_UUIDCache.TryGetValue(userID, out account)) | ||
50 | { | 67 | { |
51 | return userProfile.CurrentAgent; | 68 | //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); |
69 | return account; | ||
52 | } | 70 | } |
53 | 71 | ||
54 | return null; | 72 | return null; |
55 | } | 73 | } |
56 | 74 | ||
57 | public override UserProfileData SetupMasterUser(string firstName, string lastName) | 75 | public UserAccount Get(string name) |
58 | { | 76 | { |
59 | //throw new Exception("The method or operation is not implemented."); | 77 | if (!m_NameCache.ContainsKey(name)) |
60 | return null; | 78 | return null; |
61 | } | ||
62 | 79 | ||
63 | public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) | 80 | UserAccount account = null; |
64 | { | 81 | if (m_UUIDCache.TryGetValue(m_NameCache[name], out account)) |
65 | //throw new Exception("The method or operation is not implemented."); | 82 | return account; |
66 | return null; | ||
67 | } | ||
68 | 83 | ||
69 | public override UserProfileData SetupMasterUser(UUID uuid) | ||
70 | { | ||
71 | //throw new Exception("The method or operation is not implemented."); | ||
72 | return null; | 84 | return null; |
73 | } | 85 | } |
74 | } | 86 | } |