Enable caching of extraInfos.
This commit is contained in:
parent
a4f4447c5e
commit
670d8f18cb
1 changed files with 18 additions and 8 deletions
|
@ -10,10 +10,19 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
const PARAMETERS = array();
|
const PARAMETERS = array();
|
||||||
|
|
||||||
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(){
|
||||||
|
return array("items" => $this->getItems(), "extraInfos" => $this->getExtraInfos());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return items stored in the bridge
|
* Return items stored in the bridge
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
@ -142,8 +151,12 @@ 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();
|
$cached = $this->cache->loadData();
|
||||||
return;
|
if(isset($cached['items']) && isset($cached['extraInfos'])){
|
||||||
|
$this->items = $cached['items'];
|
||||||
|
$this->extraInfos = $cached['extraInfos'];
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +167,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;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +189,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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,10 +209,7 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getExtraInfos(){
|
public function getExtraInfos(){
|
||||||
$extraInfos = array();
|
return array("name" => $this->getName(), "uri" => $this->getURI());
|
||||||
$extraInfos['name'] = $this->getName();
|
|
||||||
$extraInfos['uri'] = $this->getURI();
|
|
||||||
return $extraInfos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCache(\CacheInterface $cache){
|
public function setCache(\CacheInterface $cache){
|
||||||
|
|
Loading…
Reference in a new issue