diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
3 files changed, 42 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 07fee79..ce0ca40 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -142,26 +142,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
142 | 142 | ||
143 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | 143 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) |
144 | { | 144 | { |
145 | UserAccount account = m_Cache.Get(userID); | 145 | bool inCache = false; |
146 | if (account != null) | 146 | UserAccount account = m_Cache.Get(userID, out inCache); |
147 | if (inCache) | ||
147 | return account; | 148 | return account; |
148 | 149 | ||
149 | account = m_UserService.GetUserAccount(scopeID, userID); | 150 | account = m_UserService.GetUserAccount(scopeID, userID); |
150 | if (account != null) | 151 | m_Cache.Cache(userID, account); |
151 | m_Cache.Cache(account); | ||
152 | 152 | ||
153 | return account; | 153 | return account; |
154 | } | 154 | } |
155 | 155 | ||
156 | public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | 156 | public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) |
157 | { | 157 | { |
158 | UserAccount account = m_Cache.Get(firstName + " " + lastName); | 158 | bool inCache = false; |
159 | if (account != null) | 159 | UserAccount account = m_Cache.Get(firstName + " " + lastName, out inCache); |
160 | if (inCache) | ||
160 | return account; | 161 | return account; |
161 | 162 | ||
162 | account = m_UserService.GetUserAccount(scopeID, firstName, lastName); | 163 | account = m_UserService.GetUserAccount(scopeID, firstName, lastName); |
163 | if (account != null) | 164 | if (account != null) |
164 | m_Cache.Cache(account); | 165 | m_Cache.Cache(account.PrincipalID, account); |
165 | 166 | ||
166 | return account; | 167 | return account; |
167 | } | 168 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 1140692..488dbd5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -119,26 +119,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
119 | 119 | ||
120 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) | 120 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) |
121 | { | 121 | { |
122 | UserAccount account = m_Cache.Get(userID); | 122 | bool inCache = false; |
123 | if (account != null) | 123 | UserAccount account = m_Cache.Get(userID, out inCache); |
124 | if (inCache) | ||
124 | return account; | 125 | return account; |
125 | 126 | ||
126 | account = base.GetUserAccount(scopeID, userID); | 127 | account = base.GetUserAccount(scopeID, userID); |
127 | if (account != null) | 128 | m_Cache.Cache(userID, account); |
128 | m_Cache.Cache(account); | ||
129 | 129 | ||
130 | return account; | 130 | return account; |
131 | } | 131 | } |
132 | 132 | ||
133 | public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | 133 | public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) |
134 | { | 134 | { |
135 | UserAccount account = m_Cache.Get(firstName + " " + lastName); | 135 | bool inCache = false; |
136 | if (account != null) | 136 | UserAccount account = m_Cache.Get(firstName + " " + lastName, out inCache); |
137 | if (inCache) | ||
137 | return account; | 138 | return account; |
138 | 139 | ||
139 | account = base.GetUserAccount(scopeID, firstName, lastName); | 140 | account = base.GetUserAccount(scopeID, firstName, lastName); |
140 | if (account != null) | 141 | if (account != null) |
141 | m_Cache.Cache(account); | 142 | m_Cache.Cache(account.PrincipalID, account); |
142 | 143 | ||
143 | return account; | 144 | return account; |
144 | } | 145 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index e430fc7..a355661 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs | |||
@@ -36,50 +36,58 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
36 | { | 36 | { |
37 | public class UserAccountCache | 37 | public class UserAccountCache |
38 | { | 38 | { |
39 | //private static readonly ILog m_log = | 39 | private static readonly ILog m_log = |
40 | // LogManager.GetLogger( | 40 | LogManager.GetLogger( |
41 | // MethodBase.GetCurrentMethod().DeclaringType); | 41 | MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | private ExpiringCache<UUID, UserAccount> m_UUIDCache; | |
43 | private ICnmCache<UUID, UserAccount> m_UUIDCache; | 43 | private ExpiringCache<string, UUID> m_NameCache; |
44 | private Dictionary<string, UUID> m_NameCache; | ||
45 | 44 | ||
46 | public UserAccountCache() | 45 | public UserAccountCache() |
47 | { | 46 | { |
48 | // Warning: the size values are a bit fuzzy. What matters | 47 | // Warning: the size values are a bit fuzzy. What matters |
49 | // most for this cache is the count value (128 entries). | 48 | // most for this cache is the count value (128 entries). |
50 | m_UUIDCache = CnmSynchronizedCache<UUID, UserAccount>.Synchronized(new CnmMemoryCache<UUID, UserAccount>( | 49 | m_UUIDCache = new ExpiringCache<UUID, UserAccount>(); |
51 | 128, 128*512, TimeSpan.FromMinutes(30.0))); | 50 | m_NameCache = new ExpiringCache<string, UUID>(); // this one is unbound |
52 | m_NameCache = new Dictionary<string, UUID>(); // this one is unbound | ||
53 | } | 51 | } |
54 | 52 | ||
55 | public void Cache(UserAccount account) | 53 | public void Cache(UUID userID, UserAccount account) |
56 | { | 54 | { |
57 | m_UUIDCache.Set(account.PrincipalID, account, 512); | 55 | // Cache even null accounts |
58 | m_NameCache[account.Name] = account.PrincipalID; | 56 | m_UUIDCache.AddOrUpdate(userID, account, DateTime.Now + TimeSpan.FromMinutes(2.0d)); |
57 | if (account != null) | ||
58 | m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, DateTime.Now + TimeSpan.FromMinutes(2.0d)); | ||
59 | 59 | ||
60 | //m_log.DebugFormat("[USER CACHE]: cached user {0} {1}", account.FirstName, account.LastName); | 60 | m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); |
61 | } | 61 | } |
62 | 62 | ||
63 | public UserAccount Get(UUID userID) | 63 | public UserAccount Get(UUID userID, out bool inCache) |
64 | { | 64 | { |
65 | UserAccount account = null; | 65 | UserAccount account = null; |
66 | inCache = false; | ||
66 | if (m_UUIDCache.TryGetValue(userID, out account)) | 67 | if (m_UUIDCache.TryGetValue(userID, out account)) |
67 | { | 68 | { |
68 | //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); | 69 | //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); |
70 | inCache = true; | ||
69 | return account; | 71 | return account; |
70 | } | 72 | } |
71 | 73 | ||
72 | return null; | 74 | return null; |
73 | } | 75 | } |
74 | 76 | ||
75 | public UserAccount Get(string name) | 77 | public UserAccount Get(string name, out bool inCache) |
76 | { | 78 | { |
77 | if (!m_NameCache.ContainsKey(name)) | 79 | inCache = false; |
80 | if (!m_NameCache.Contains(name)) | ||
78 | return null; | 81 | return null; |
79 | 82 | ||
80 | UserAccount account = null; | 83 | UserAccount account = null; |
81 | if (m_UUIDCache.TryGetValue(m_NameCache[name], out account)) | 84 | UUID uuid = UUID.Zero; |
82 | return account; | 85 | if (m_NameCache.TryGetValue(name, out uuid)) |
86 | if (m_UUIDCache.TryGetValue(uuid, out account)) | ||
87 | { | ||
88 | inCache = true; | ||
89 | return account; | ||
90 | } | ||
83 | 91 | ||
84 | return null; | 92 | return null; |
85 | } | 93 | } |