aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Asset
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset')
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs57
1 files changed, 54 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 9a165fb..35d726f 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -92,6 +92,15 @@ namespace Flotsam.RegionModules.AssetCache
92 /// ; long (in miliseconds) to block a request thread while trying to complete 92 /// ; long (in miliseconds) to block a request thread while trying to complete
93 /// ; writing to disk. 93 /// ; writing to disk.
94 /// WaitOnInprogressTimeout = 3000 94 /// WaitOnInprogressTimeout = 3000
95 ///
96 /// ; Number of tiers to use for cache directories (current valid range 1 to 3)
97 /// CacheDirectoryTiers = 2
98 ///
99 /// ; Number of letters per path tier, 1 will create 16 directories per tier, 2 - 256, 3 - 4096 and 4 - 65K
100 /// CacheDirectoryTierLength = 3
101 ///
102 /// ; Warning level for cache directory size
103 /// CacheWarnAt = 30000
95 /// ------- 104 /// -------
96 /// </summary> 105 /// </summary>
97 106
@@ -138,6 +147,10 @@ namespace Flotsam.RegionModules.AssetCache
138 private TimeSpan m_FileExpiration = TimeSpan.Zero; 147 private TimeSpan m_FileExpiration = TimeSpan.Zero;
139 private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.Zero; 148 private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.Zero;
140 149
150 private static int m_CacheDirectoryTiers = 1;
151 private static int m_CacheDirectoryTierLen = 4;
152 private static int m_CacheWarnAt = 30000;
153
141 private System.Timers.Timer m_CachCleanTimer = new System.Timers.Timer(); 154 private System.Timers.Timer m_CachCleanTimer = new System.Timers.Timer();
142 155
143 public FlotsamAssetCache() 156 public FlotsamAssetCache()
@@ -204,6 +217,28 @@ namespace Flotsam.RegionModules.AssetCache
204 { 217 {
205 m_CachCleanTimer.Enabled = false; 218 m_CachCleanTimer.Enabled = false;
206 } 219 }
220
221 m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", 1);
222 if (m_CacheDirectoryTiers < 1)
223 {
224 m_CacheDirectoryTiers = 1;
225 }
226 else if (m_CacheDirectoryTiers > 3)
227 {
228 m_CacheDirectoryTiers = 3;
229 }
230
231 m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLen", 1);
232 if (m_CacheDirectoryTierLen < 1)
233 {
234 m_CacheDirectoryTierLen = 1;
235 }
236 else if (m_CacheDirectoryTierLen > 4)
237 {
238 m_CacheDirectoryTierLen = 4;
239 }
240
241 m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", 30000);
207 } 242 }
208 } 243 }
209 } 244 }
@@ -447,6 +482,17 @@ namespace Flotsam.RegionModules.AssetCache
447 File.Delete(file); 482 File.Delete(file);
448 } 483 }
449 } 484 }
485
486 int dirSize = Directory.GetFiles(dir).Length;
487 if ( dirSize == 0)
488 {
489 Directory.Delete(dir);
490 }
491 else if (dirSize >= m_CacheWarnAt)
492 {
493 m_log.WarnFormat("[ASSET CACHE]: Cache folder exceeded CacheWarnAt limit {0} {1}. Suggest increasing tiers, tier length, or reducing cache expiration", dir, dirSize);
494 }
495
450 } 496 }
451 } 497 }
452 498
@@ -458,9 +504,14 @@ namespace Flotsam.RegionModules.AssetCache
458 id = id.Replace(c, '_'); 504 id = id.Replace(c, '_');
459 } 505 }
460 506
461 string p = id.Substring(id.Length - 4); 507 string path = m_CacheDirectory;
462 p = Path.Combine(p, id); 508 for (int p = 1; p <= m_CacheDirectoryTiers; p++)
463 return Path.Combine(m_CacheDirectory, p); 509 {
510 string pathPart = id.Substring(id.Length - (p * m_CacheDirectoryTierLen), m_CacheDirectoryTierLen);
511 path = Path.Combine(path, pathPart);
512 }
513
514 return Path.Combine(path, id);
464 } 515 }
465 516
466 private void WriteFileCache(string filename, AssetBase asset) 517 private void WriteFileCache(string filename, AssetBase asset)