/// <summary> /// Attempts to start the DiskCache using the current settings. Returns true if successful or if already started. Returns false on a configuration error. /// Called by Install() /// </summary> public bool Start() { if (!IsConfigurationValid()) { return(false); } lock (_startSync) { if (_started) { return(true); } if (!IsConfigurationValid()) { return(false); } //Init the writer. writer = new WebConfigWriter(this, PhysicalCacheDir); if (!AsyncModuleMode) { cache = new CustomDiskCache(this, PhysicalCacheDir, 4096, 1024 * 1024 * 30); } if (AsyncModuleMode) { asyncCache = new AsyncCustomDiskCache(this, PhysicalCacheDir, 4096, 1024 * 1024 * 30); } //Init the cleanup strategy var cleanupStrategy = new CleanupStrategy(); //Default settings if null cleanupStrategy.TargetItemsPerFolder = 50; //Init the cleanup worker cleaner = new CleanupManager(this, AsyncModuleMode ? (ICleanableCache)asyncCache : (ICleanableCache)cache, cleanupStrategy); //If we're running with subfolders, enqueue the cache root for cleanup (after the 5 minute delay) //so we don't eternally 'skip' files in the root or in other unused subfolders (since only 'accessed' subfolders are ever cleaned ). if (cleaner != null) { cleaner.CleanAll(); } //Started successfully _started = true; return(true); } }