From c4efeb0f7ca363b968e18a9bda7ff10996c9f000 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 5 Jun 2015 11:46:13 -0700 Subject: 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... --- .../SimianGrid/SimianInventoryServiceConnector.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs index fdeea18..a92c4fb 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs @@ -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 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(); + } 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(); } } } @@ -271,6 +279,10 @@ namespace OpenSim.Services.Connectors.SimianGrid /// 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; + } } } } -- cgit v1.1