diff --git a/source/lib/DownloadDispatcher/Source/PluginBase.class.php b/source/lib/DownloadDispatcher/Source/PluginBase.class.php index 72567c3..1ec4ed9 100644 --- a/source/lib/DownloadDispatcher/Source/PluginBase.class.php +++ b/source/lib/DownloadDispatcher/Source/PluginBase.class.php @@ -2,11 +2,26 @@ class DownloadDispatcher_Source_PluginBase extends DownloadDispatcher_PluginBase { - static protected $source_cache = array(); + static protected $cache; + + static protected $source_cache = null; + static protected $cache_file = 'source_cache'; + static protected $cache_lifetime = 86400; protected function init_cache() { + if ( ! static::$cache) { + static::$cache = DownloadDispatcher_Main::instance()->cache(); + } + + if (is_null(static::$source_cache)) { + try { + static::$source_cache = static::$cache->fetch(static::$cache_file, static::$cache_lifetime); + } catch (SihnonFramework_Exception_CacheObjectNotFound $e) { + static::$source_cache = array(); + } + } + if ( ! array_key_exists(get_called_class(), static::$source_cache)) { - // TODO - attempt to load data from persistent storage static::$source_cache[get_called_class()] = array(); } } @@ -18,7 +33,7 @@ class DownloadDispatcher_Source_PluginBase extends DownloadDispatcher_PluginBase static::$source_cache[get_called_class()][] = $file; } - // TODO - flush cache to persistent storage + static::$cache->store($cache_file, static::$source_cache); } protected function check_processed($file) {