From feca9fd15385a5e2df27b5a3cc4ea3253be00909 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 29 Dec 2016 11:53:38 +0000 Subject: Add an option to update the file access time even when an asset is found in cache. When the cache is shared between multiple sims, it is often more efficient to have a single expire job run from cron. Updating file access times is vital to the functioning of such setups. --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index e7f4981..5400c91 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -110,6 +110,7 @@ namespace OpenSim.Region.CoreModules.Asset private Dictionary weakAssetReferences = new Dictionary(); private object weakAssetReferencesLock = new object(); + private bool m_updateFileTimeOnCacheHit = false; public FlotsamAssetCache() { @@ -156,6 +157,8 @@ namespace OpenSim.Region.CoreModules.Asset m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", m_MemoryCacheEnabled); m_MemoryExpiration = assetConfig.GetDouble("MemoryCacheTimeout", m_MemoryExpiration); m_MemoryExpiration *= 3600.0; // config in hours to seconds + + m_updateFileTimeOnCacheHit = assetConfig.GetBoolean("UpdateFileTimeOnCacheHit", m_updateFileTimeOnCacheHit); #if WAIT_ON_INPROGRESS_REQUESTS m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); @@ -513,12 +516,24 @@ namespace OpenSim.Region.CoreModules.Asset AssetBase asset = null; asset = GetFromWeakReference(id); + if (asset != null && m_updateFileTimeOnCacheHit) + { + string filename = GetFileName(id); + UpdateFileLastAccessTime(filename); + } if (m_MemoryCacheEnabled && asset == null) { asset = GetFromMemoryCache(id); if(asset != null) + { UpdateWeakReference(id,asset); + if (m_updateFileTimeOnCacheHit) + { + string filename = GetFileName(id); + UpdateFileLastAccessTime(filename); + } + } } if (asset == null && m_FileCacheEnabled) -- cgit v1.1