0
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-07-05 05:23:55 +00:00

[BridgeAbstract] add protected property extraInfos and function getCachable()

create  function getCachable()
modify function setDatas in call to cache->savedata
This commit is contained in:
Badet Aurélien 2016-11-30 18:22:55 +01:00 committed by GitHub
parent da82b3090a
commit 15d742e938

View File

@ -11,10 +11,22 @@ abstract class BridgeAbstract implements BridgeInterface {
const FORMATS = array(); // array of compatibles formats or null const FORMATS = array(); // array of compatibles formats or null
protected $cache; protected $cache;
protected $extraInfos;
protected $items = array(); protected $items = array();
protected $inputs = array(); protected $inputs = array();
protected $queriedContext = ''; protected $queriedContext = '';
/**
* Return cachable datas (extrainfos and items) stored in the bridge
* @return mixed
*/
public function getCachable(){
$cachable = array();
$cachable["items"] = $this->getItems();
$cachable["extraInfos"] = $this->getExtraInfos();
return $cachable;
}
/** /**
* Return items stored in the bridge * Return items stored in the bridge
* @return mixed * @return mixed
@ -143,7 +155,10 @@ abstract class BridgeAbstract implements BridgeInterface {
if($time !== false if($time !== false
&& (time() - static::CACHE_TIMEOUT < $time) && (time() - static::CACHE_TIMEOUT < $time)
&& (!defined('DEBUG') || DEBUG !== true)){ && (!defined('DEBUG') || DEBUG !== true)){
$this->items = $this->cache->loadData(); $cachable = array();
$cachable = $this->cache->loadData();
$this->items = $cachable["items"];
$this->extraInfos = $cachable["extraInfos"];
return; return;
} }
} }
@ -155,7 +170,7 @@ abstract class BridgeAbstract implements BridgeInterface {
$this->collectData(); $this->collectData();
if(!is_null($this->cache)){ if(!is_null($this->cache)){
$this->cache->saveData($this->getItems()); $this->cache->saveData($this->getCachable());
} }
return; return;
} }
@ -177,7 +192,7 @@ abstract class BridgeAbstract implements BridgeInterface {
$this->collectData(); $this->collectData();
if(!is_null($this->cache)){ if(!is_null($this->cache)){
$this->cache->saveData($this->getItems()); $this->cache->saveData($this->getCachable());
} }
} }