/// <summary> /// Attempts to start the DiskCache using the current settings. Returns true if succesful 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); //Init the inner cache cache = new CustomDiskCache(this, PhysicalCacheDir, Subfolders, HashModifiedDate,AsyncBufferSize); //Init the cleanup strategy if (AutoClean && cleanupStrategy == null) cleanupStrategy = new CleanupStrategy(); //Default settings if null //Init the cleanup worker if (AutoClean) cleaner = new CleanupManager(this, 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(); if (log != null) log.Info("DiskCache started successfully."); //Started successfully _started = true; return true; } }
/// <summary> /// Returns true if stopped succesfully. Cannot be restarted /// </summary> /// <returns></returns> public bool Stop() { if (cleaner != null) cleaner.Dispose(); cleaner = null; return true; }
/// <summary> /// Attempts to start the DiskCache using the current settings. Returns true if succesful 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); //Init the inner cache cache = new CustomDiskCache(this, PhysicalCacheDir, 512, true, 1024 * 1024 * 30); //30MB //Init the cleanup strategy var cleanupStrategy = new CleanupStrategy(); //Default settings if null cleanupStrategy.TargetItemsPerFolder = 50; //Init the cleanup worker cleaner = new CleanupManager(this, 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; } }