From a1759292c811829b3fa5a2016dd0fbb448e81c3c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 30 Jul 2016 03:31:03 +0100 Subject: [PATCH] add a regionInfoCache cache add region with expire time option --- .../Grid/RegionInfoCache.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs index 8403362659..77f002e558 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs @@ -38,7 +38,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { public class RegionInfoCache { - private const double CACHE_EXPIRATION_SECONDS = 120; // 2 minutes opensim regions change a lot + private const float CACHE_EXPIRATION_SECONDS = 120; // 2 minutes opensim regions change a lot // private static readonly ILog m_log = // LogManager.GetLogger( @@ -68,6 +68,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_Cache.AddOrUpdate(scopeID, rinfo, CACHE_EXPIRATION_SECONDS); } + public void Cache(UUID scopeID, UUID regionID, GridRegion rinfo, float expireSeconds) + { + // for now, do not cache negative results; this is because + // we need to figure out how to handle regions coming online + // in a timely way + if (rinfo == null) + return; + + m_Cache.AddOrUpdate(scopeID, rinfo, expireSeconds); + } + public GridRegion Get(UUID scopeID, UUID regionID, out bool inCache) { inCache = false; @@ -255,7 +266,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid timer.Start(); } - public bool Add(UUID scope, GridRegion region, double expirationSeconds) + public bool Add(UUID scope, GridRegion region, float expirationSeconds) { if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms"); @@ -284,7 +295,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid finally { Monitor.Exit(syncRoot);} } - public bool AddOrUpdate(UUID scope, GridRegion region, double expirationSeconds) + public bool AddOrUpdate(UUID scope, GridRegion region, float expirationSeconds) { if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms");