Added caching to Sources
Added caching to Sources. Updated the source browser to mark sources which are still cached
This commit is contained in:
@@ -6,15 +6,33 @@ class HandBrakeCluster_Rips_Source {
|
||||
const PM_CHAPTER = 1;
|
||||
const PM_AUDIO = 2;
|
||||
const PM_SUBTITLE = 3;
|
||||
|
||||
|
||||
protected $source;
|
||||
protected $output;
|
||||
protected $titles = array();
|
||||
|
||||
public function __construct($source) {
|
||||
$this->source = $source;
|
||||
public function __construct($source_filename, $use_cache) {
|
||||
$this->source = $source_filename;
|
||||
|
||||
$this->scan();
|
||||
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$cache = $main->cache();
|
||||
$config = $main->config();
|
||||
|
||||
if ($use_cache) {
|
||||
$cache->store($this->source, serialize($this), $config->get('rips.cache_ttl'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function load($source_filename, $use_cache = true) {
|
||||
$cache = HandBrakeCluster_Main::instance()->cache();
|
||||
|
||||
if ($use_cache && $cache->exists($source_filename)) {
|
||||
return unserialize($cache->fetch($source_filename));
|
||||
} else {
|
||||
return new HandBrakeCluster_Rips_Source($source_filename, $use_cache);
|
||||
}
|
||||
}
|
||||
|
||||
protected function scan() {
|
||||
@@ -124,6 +142,14 @@ class HandBrakeCluster_Rips_Source {
|
||||
}
|
||||
}
|
||||
|
||||
public static function isCached($source_filename) {
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$cache = $main->cache();
|
||||
$config = $main->config();
|
||||
|
||||
return $cache->exists($source_filename, $config->get('rips.cache_ttl'));
|
||||
}
|
||||
|
||||
public function addTitle(HandBrakeCluster_Rips_SourceTitle $title) {
|
||||
$this->titles[] = $title;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user