Make the internal flotsam asset cache defaults match config-include/FlotsamCache.ini.example. Enable the flotsam console commands even if FlotsamCache.ini isn't present.

For the most part, defaults are made to match those already in FlotsamCache.ini.example.
The one exception is that the 48 hour file timeout from the code is used instead of the 0 hours that was in the example file.  This can be tweaked if necessary.
Most importantly, the default cache directory is now ./assetcache (as in FlotsamCache.ini.example) rather than ./FlotsamAssetCache (as was the internal code default).
Therefore, if you were using flotasm without using the config file, then please rename your cache directory or start using the ini file and change the default there if you want to keep using your existing cache.
bulletsim
Justin Clark-Casey (justincc) 2011-06-11 00:04:21 +01:00
parent fc7e17baf7
commit b13b54c526
2 changed files with 39 additions and 33 deletions

View File

@ -64,13 +64,13 @@ namespace Flotsam.RegionModules.AssetCache
private bool m_Enabled; private bool m_Enabled;
private const string m_ModuleName = "FlotsamAssetCache"; private const string m_ModuleName = "FlotsamAssetCache";
private const string m_DefaultCacheDirectory = m_ModuleName; private const string m_DefaultCacheDirectory = "./assetcache";
private string m_CacheDirectory = m_DefaultCacheDirectory; private string m_CacheDirectory = m_DefaultCacheDirectory;
private readonly List<char> m_InvalidChars = new List<char>(); private readonly List<char> m_InvalidChars = new List<char>();
private int m_LogLevel = 0; private int m_LogLevel = 0;
private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests private ulong m_HitRateDisplay = 100; // How often to display hit statistics, given in requests
private static ulong m_Requests; private static ulong m_Requests;
private static ulong m_RequestsForInprogress; private static ulong m_RequestsForInprogress;
@ -87,14 +87,14 @@ namespace Flotsam.RegionModules.AssetCache
#endif #endif
private ExpiringCache<string, AssetBase> m_MemoryCache; private ExpiringCache<string, AssetBase> m_MemoryCache;
private bool m_MemoryCacheEnabled = true; private bool m_MemoryCacheEnabled = false;
// Expiration is expressed in hours. // Expiration is expressed in hours.
private const double m_DefaultMemoryExpiration = 1.0; private const double m_DefaultMemoryExpiration = 2;
private const double m_DefaultFileExpiration = 48; private const double m_DefaultFileExpiration = 48;
private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration);
private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration);
private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(m_DefaultFileExpiration); private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(0.166);
private static int m_CacheDirectoryTiers = 1; private static int m_CacheDirectoryTiers = 1;
private static int m_CacheDirectoryTierLen = 3; private static int m_CacheDirectoryTierLen = 3;
@ -141,26 +141,38 @@ namespace Flotsam.RegionModules.AssetCache
IConfig assetConfig = source.Configs["AssetCache"]; IConfig assetConfig = source.Configs["AssetCache"];
if (assetConfig == null) if (assetConfig == null)
{ {
m_log.Warn("[FLOTSAM ASSET CACHE]: AssetCache missing from OpenSim.ini, using defaults."); m_log.Warn(
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); "[FLOTSAM ASSET CACHE]: AssetCache section missing from config (not copied config-include/FlotsamCache.ini.example? Using defaults.");
return;
} }
else
{
m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory);
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_CacheDirectory);
m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", m_MemoryCacheEnabled);
m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration));
#if WAIT_ON_INPROGRESS_REQUESTS #if WAIT_ON_INPROGRESS_REQUESTS
m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000);
#endif #endif
m_LogLevel = assetConfig.GetInt("LogLevel", 0); m_LogLevel = assetConfig.GetInt("LogLevel", m_LogLevel);
m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000); m_HitRateDisplay = (ulong)assetConfig.GetLong("HitRateDisplay", (long)m_HitRateDisplay);
m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration));
m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); m_FileExpirationCleanupTimer
= TimeSpan.FromHours(
assetConfig.GetDouble("FileCleanupTimer", m_FileExpirationCleanupTimer.TotalHours));
m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", m_CacheDirectoryTiers);
m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen);
m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt);
m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", m_DeepScanBeforePurge);
}
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory);
if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero))
{ {
m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds);
@ -170,7 +182,6 @@ namespace Flotsam.RegionModules.AssetCache
m_CacheCleanTimer.Start(); m_CacheCleanTimer.Start();
} }
m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", 1);
if (m_CacheDirectoryTiers < 1) if (m_CacheDirectoryTiers < 1)
{ {
m_CacheDirectoryTiers = 1; m_CacheDirectoryTiers = 1;
@ -180,7 +191,6 @@ namespace Flotsam.RegionModules.AssetCache
m_CacheDirectoryTiers = 3; m_CacheDirectoryTiers = 3;
} }
m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", 3);
if (m_CacheDirectoryTierLen < 1) if (m_CacheDirectoryTierLen < 1)
{ {
m_CacheDirectoryTierLen = 1; m_CacheDirectoryTierLen = 1;
@ -190,14 +200,10 @@ namespace Flotsam.RegionModules.AssetCache
m_CacheDirectoryTierLen = 4; m_CacheDirectoryTierLen = 4;
} }
m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", 30000); MainConsole.Instance.Commands.AddCommand(Name, true, "fcache status", "fcache status", "Display cache status", HandleConsoleCommand);
MainConsole.Instance.Commands.AddCommand(Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand);
m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", false); MainConsole.Instance.Commands.AddCommand(Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand);
MainConsole.Instance.Commands.AddCommand(Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand);
MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache status", "fcache status", "Display cache status", HandleConsoleCommand);
MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand);
MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand);
MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand);
} }
} }
} }

View File

@ -29,7 +29,7 @@
; How long {in hours} to keep assets cached on disk, .5 == 30 minutes ; How long {in hours} to keep assets cached on disk, .5 == 30 minutes
; Specify 0 if you do not want your disk cache to expire ; Specify 0 if you do not want your disk cache to expire
FileCacheTimeout = 0 FileCacheTimeout = 48
; How often {in hours} should the disk be checked for expired filed ; How often {in hours} should the disk be checked for expired filed
; Specify 0 to disable expiration checking ; Specify 0 to disable expiration checking