diff options
author | Melanie Thielker | 2016-12-29 11:53:38 +0000 |
---|---|---|
committer | Melanie Thielker | 2016-12-29 11:53:38 +0000 |
commit | feca9fd15385a5e2df27b5a3cc4ea3253be00909 (patch) | |
tree | e8305f5e83f185e2b1363df38a787fa98c1f6d38 /OpenSim/Region | |
parent | expire also from weak references (diff) | |
download | opensim-SC_OLD-feca9fd15385a5e2df27b5a3cc4ea3253be00909.zip opensim-SC_OLD-feca9fd15385a5e2df27b5a3cc4ea3253be00909.tar.gz opensim-SC_OLD-feca9fd15385a5e2df27b5a3cc4ea3253be00909.tar.bz2 opensim-SC_OLD-feca9fd15385a5e2df27b5a3cc4ea3253be00909.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 15 |
1 files changed, 15 insertions, 0 deletions
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 | |||
110 | 110 | ||
111 | private Dictionary<string,WeakReference> weakAssetReferences = new Dictionary<string, WeakReference>(); | 111 | private Dictionary<string,WeakReference> weakAssetReferences = new Dictionary<string, WeakReference>(); |
112 | private object weakAssetReferencesLock = new object(); | 112 | private object weakAssetReferencesLock = new object(); |
113 | private bool m_updateFileTimeOnCacheHit = false; | ||
113 | 114 | ||
114 | public FlotsamAssetCache() | 115 | public FlotsamAssetCache() |
115 | { | 116 | { |
@@ -156,6 +157,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
156 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", m_MemoryCacheEnabled); | 157 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", m_MemoryCacheEnabled); |
157 | m_MemoryExpiration = assetConfig.GetDouble("MemoryCacheTimeout", m_MemoryExpiration); | 158 | m_MemoryExpiration = assetConfig.GetDouble("MemoryCacheTimeout", m_MemoryExpiration); |
158 | m_MemoryExpiration *= 3600.0; // config in hours to seconds | 159 | m_MemoryExpiration *= 3600.0; // config in hours to seconds |
160 | |||
161 | m_updateFileTimeOnCacheHit = assetConfig.GetBoolean("UpdateFileTimeOnCacheHit", m_updateFileTimeOnCacheHit); | ||
159 | 162 | ||
160 | #if WAIT_ON_INPROGRESS_REQUESTS | 163 | #if WAIT_ON_INPROGRESS_REQUESTS |
161 | m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); | 164 | m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); |
@@ -513,12 +516,24 @@ namespace OpenSim.Region.CoreModules.Asset | |||
513 | 516 | ||
514 | AssetBase asset = null; | 517 | AssetBase asset = null; |
515 | asset = GetFromWeakReference(id); | 518 | asset = GetFromWeakReference(id); |
519 | if (asset != null && m_updateFileTimeOnCacheHit) | ||
520 | { | ||
521 | string filename = GetFileName(id); | ||
522 | UpdateFileLastAccessTime(filename); | ||
523 | } | ||
516 | 524 | ||
517 | if (m_MemoryCacheEnabled && asset == null) | 525 | if (m_MemoryCacheEnabled && asset == null) |
518 | { | 526 | { |
519 | asset = GetFromMemoryCache(id); | 527 | asset = GetFromMemoryCache(id); |
520 | if(asset != null) | 528 | if(asset != null) |
529 | { | ||
521 | UpdateWeakReference(id,asset); | 530 | UpdateWeakReference(id,asset); |
531 | if (m_updateFileTimeOnCacheHit) | ||
532 | { | ||
533 | string filename = GetFileName(id); | ||
534 | UpdateFileLastAccessTime(filename); | ||
535 | } | ||
536 | } | ||
522 | } | 537 | } |
523 | 538 | ||
524 | if (asset == null && m_FileCacheEnabled) | 539 | if (asset == null && m_FileCacheEnabled) |