Upgraded the Simian inventory connector with an item cache, too, so that it doesn't get awfully out of sync with the improvements I'm making to the robust service connectors, which are being fully leveraged by the simulator. This Simian connector needs more love...

fsassets
Diva Canto 2015-06-05 11:46:13 -07:00
parent 96f0c6f074
commit c4efeb0f7c
1 changed files with 17 additions and 1 deletions

View File

@ -74,6 +74,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
// private object m_gestureSyncRoot = new object();
private bool m_Enabled = false;
private const double CACHE_EXPIRATION_SECONDS = 20.0;
private static ExpiringCache<UUID, InventoryItemBase> m_ItemCache;
#region ISharedRegionModule
public Type ReplaceableInterface { get { return null; } }
@ -99,6 +102,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
url = url + '/';
m_serverUrl = url;
if (m_ItemCache == null)
m_ItemCache = new ExpiringCache<UUID, InventoryItemBase>();
}
public void Initialise(IConfigSource source)
@ -132,6 +138,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
{
m_userServerUrl = serviceUrl;
m_Enabled = true;
if (m_ItemCache == null)
m_ItemCache = new ExpiringCache<UUID, InventoryItemBase>();
}
}
}
@ -271,6 +279,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
/// <returns></returns>
public InventoryItemBase GetItem(InventoryItemBase item)
{
InventoryItemBase retrieved = null;
if (m_ItemCache.TryGetValue(item.ID, out retrieved))
return retrieved;
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "GetInventoryNode" },
@ -292,7 +304,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
for (int i = 0; i < items.Count; i++)
{
if (items[i].ID == item.ID)
return items[i];
{
retrieved = items[i];
m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS);
return retrieved;
}
}
}
}