diff options
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 64 | ||||
-rw-r--r-- | bin/config-include/FlotsamCache.ini.example | 2 |
2 files changed, 36 insertions, 30 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 9adb68b..d9280c6 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -64,13 +64,13 @@ namespace Flotsam.RegionModules.AssetCache | |||
64 | private bool m_Enabled; | 64 | private bool m_Enabled; |
65 | 65 | ||
66 | private const string m_ModuleName = "FlotsamAssetCache"; | 66 | private const string m_ModuleName = "FlotsamAssetCache"; |
67 | private const string m_DefaultCacheDirectory = m_ModuleName; | 67 | private const string m_DefaultCacheDirectory = "./assetcache"; |
68 | private string m_CacheDirectory = m_DefaultCacheDirectory; | 68 | private string m_CacheDirectory = m_DefaultCacheDirectory; |
69 | 69 | ||
70 | private readonly List<char> m_InvalidChars = new List<char>(); | 70 | private readonly List<char> m_InvalidChars = new List<char>(); |
71 | 71 | ||
72 | private int m_LogLevel = 0; | 72 | private int m_LogLevel = 0; |
73 | private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests | 73 | private ulong m_HitRateDisplay = 100; // How often to display hit statistics, given in requests |
74 | 74 | ||
75 | private static ulong m_Requests; | 75 | private static ulong m_Requests; |
76 | private static ulong m_RequestsForInprogress; | 76 | private static ulong m_RequestsForInprogress; |
@@ -87,14 +87,14 @@ namespace Flotsam.RegionModules.AssetCache | |||
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | private ExpiringCache<string, AssetBase> m_MemoryCache; | 89 | private ExpiringCache<string, AssetBase> m_MemoryCache; |
90 | private bool m_MemoryCacheEnabled = true; | 90 | private bool m_MemoryCacheEnabled = false; |
91 | 91 | ||
92 | // Expiration is expressed in hours. | 92 | // Expiration is expressed in hours. |
93 | private const double m_DefaultMemoryExpiration = 1.0; | 93 | private const double m_DefaultMemoryExpiration = 2; |
94 | private const double m_DefaultFileExpiration = 48; | 94 | private const double m_DefaultFileExpiration = 48; |
95 | private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); | 95 | private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); |
96 | private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); | 96 | private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); |
97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(m_DefaultFileExpiration); | 97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(0.166); |
98 | 98 | ||
99 | private static int m_CacheDirectoryTiers = 1; | 99 | private static int m_CacheDirectoryTiers = 1; |
100 | private static int m_CacheDirectoryTierLen = 3; | 100 | private static int m_CacheDirectoryTierLen = 3; |
@@ -141,26 +141,38 @@ namespace Flotsam.RegionModules.AssetCache | |||
141 | IConfig assetConfig = source.Configs["AssetCache"]; | 141 | IConfig assetConfig = source.Configs["AssetCache"]; |
142 | if (assetConfig == null) | 142 | if (assetConfig == null) |
143 | { | 143 | { |
144 | m_log.Warn("[FLOTSAM ASSET CACHE]: AssetCache missing from OpenSim.ini, using defaults."); | 144 | m_log.Warn( |
145 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); | 145 | "[FLOTSAM ASSET CACHE]: AssetCache section missing from config (not copied config-include/FlotsamCache.ini.example? Using defaults."); |
146 | return; | ||
147 | } | 146 | } |
147 | else | ||
148 | { | ||
149 | m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); | ||
148 | 150 | ||
149 | m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); | 151 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", m_MemoryCacheEnabled); |
150 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_CacheDirectory); | 152 | m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); |
153 | |||
154 | #if WAIT_ON_INPROGRESS_REQUESTS | ||
155 | m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); | ||
156 | #endif | ||
157 | |||
158 | m_LogLevel = assetConfig.GetInt("LogLevel", m_LogLevel); | ||
159 | m_HitRateDisplay = (ulong)assetConfig.GetLong("HitRateDisplay", (long)m_HitRateDisplay); | ||
151 | 160 | ||
152 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); | 161 | m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); |
153 | m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); | 162 | m_FileExpirationCleanupTimer |
163 | = TimeSpan.FromHours( | ||
164 | assetConfig.GetDouble("FileCleanupTimer", m_FileExpirationCleanupTimer.TotalHours)); | ||
154 | 165 | ||
155 | #if WAIT_ON_INPROGRESS_REQUESTS | 166 | m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", m_CacheDirectoryTiers); |
156 | m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); | 167 | m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen); |
157 | #endif | 168 | |
169 | m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt); | ||
158 | 170 | ||
159 | m_LogLevel = assetConfig.GetInt("LogLevel", 0); | 171 | m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", m_DeepScanBeforePurge); |
160 | m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000); | 172 | } |
173 | |||
174 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory); | ||
161 | 175 | ||
162 | m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); | ||
163 | m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); | ||
164 | if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) | 176 | if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) |
165 | { | 177 | { |
166 | m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); | 178 | m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); |
@@ -170,7 +182,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
170 | m_CacheCleanTimer.Start(); | 182 | m_CacheCleanTimer.Start(); |
171 | } | 183 | } |
172 | 184 | ||
173 | m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", 1); | ||
174 | if (m_CacheDirectoryTiers < 1) | 185 | if (m_CacheDirectoryTiers < 1) |
175 | { | 186 | { |
176 | m_CacheDirectoryTiers = 1; | 187 | m_CacheDirectoryTiers = 1; |
@@ -180,7 +191,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
180 | m_CacheDirectoryTiers = 3; | 191 | m_CacheDirectoryTiers = 3; |
181 | } | 192 | } |
182 | 193 | ||
183 | m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", 3); | ||
184 | if (m_CacheDirectoryTierLen < 1) | 194 | if (m_CacheDirectoryTierLen < 1) |
185 | { | 195 | { |
186 | m_CacheDirectoryTierLen = 1; | 196 | m_CacheDirectoryTierLen = 1; |
@@ -190,14 +200,10 @@ namespace Flotsam.RegionModules.AssetCache | |||
190 | m_CacheDirectoryTierLen = 4; | 200 | m_CacheDirectoryTierLen = 4; |
191 | } | 201 | } |
192 | 202 | ||
193 | m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", 30000); | 203 | MainConsole.Instance.Commands.AddCommand(Name, true, "fcache status", "fcache status", "Display cache status", HandleConsoleCommand); |
194 | 204 | MainConsole.Instance.Commands.AddCommand(Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand); | |
195 | m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", false); | 205 | MainConsole.Instance.Commands.AddCommand(Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); |
196 | 206 | MainConsole.Instance.Commands.AddCommand(Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand); | |
197 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache status", "fcache status", "Display cache status", HandleConsoleCommand); | ||
198 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand); | ||
199 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); | ||
200 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand); | ||
201 | } | 207 | } |
202 | } | 208 | } |
203 | } | 209 | } |
diff --git a/bin/config-include/FlotsamCache.ini.example b/bin/config-include/FlotsamCache.ini.example index 026dee7..1f2bf03 100644 --- a/bin/config-include/FlotsamCache.ini.example +++ b/bin/config-include/FlotsamCache.ini.example | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | ; How long {in hours} to keep assets cached on disk, .5 == 30 minutes | 30 | ; How long {in hours} to keep assets cached on disk, .5 == 30 minutes |
31 | ; Specify 0 if you do not want your disk cache to expire | 31 | ; Specify 0 if you do not want your disk cache to expire |
32 | FileCacheTimeout = 0 | 32 | FileCacheTimeout = 48 |
33 | 33 | ||
34 | ; How often {in hours} should the disk be checked for expired filed | 34 | ; How often {in hours} should the disk be checked for expired filed |
35 | ; Specify 0 to disable expiration checking | 35 | ; Specify 0 to disable expiration checking |