[index] Initialize cache before loading to bridge
Previously BridgeAbstract needed to know which exact implementation of CacheInterface was used (since we only got one right now its not a problem). Initializing the cache in index.php instead allows to change cache types more easily.
This commit is contained in:
parent
d941fa41f6
commit
5de4a59d41
2 changed files with 8 additions and 6 deletions
13
index.php
13
index.php
|
@ -117,11 +117,6 @@ try {
|
||||||
// Data retrieval
|
// Data retrieval
|
||||||
$bridge = Bridge::create($bridge);
|
$bridge = Bridge::create($bridge);
|
||||||
|
|
||||||
$cache = Cache::create('FileCache');
|
|
||||||
$cache->purgeCache();
|
|
||||||
|
|
||||||
$bridge->setCache($cache);
|
|
||||||
|
|
||||||
$noproxy = filter_input(INPUT_GET, '_noproxy', FILTER_VALIDATE_BOOLEAN);
|
$noproxy = filter_input(INPUT_GET, '_noproxy', FILTER_VALIDATE_BOOLEAN);
|
||||||
if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy){
|
if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy){
|
||||||
define('NOPROXY',true);
|
define('NOPROXY',true);
|
||||||
|
@ -132,6 +127,14 @@ try {
|
||||||
unset($params['bridge']);
|
unset($params['bridge']);
|
||||||
unset($params['format']);
|
unset($params['format']);
|
||||||
unset($params['_noproxy']);
|
unset($params['_noproxy']);
|
||||||
|
|
||||||
|
// Initialize cache
|
||||||
|
$cache = Cache::create('FileCache');
|
||||||
|
$cache->purgeCache();
|
||||||
|
$cache->setParameters($params);
|
||||||
|
|
||||||
|
// Load cache & data
|
||||||
|
$bridge->setCache($cache);
|
||||||
$bridge->setDatas($params);
|
$bridge->setDatas($params);
|
||||||
|
|
||||||
// Data transformation
|
// Data transformation
|
||||||
|
|
|
@ -138,7 +138,6 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
*/
|
*/
|
||||||
public function setDatas(array $inputs){
|
public function setDatas(array $inputs){
|
||||||
if(!is_null($this->cache)){
|
if(!is_null($this->cache)){
|
||||||
$this->cache->setParameters($inputs);
|
|
||||||
$time = $this->cache->getTime();
|
$time = $this->cache->getTime();
|
||||||
if($time !== false
|
if($time !== false
|
||||||
&& (time() - static::CACHE_TIMEOUT < $time)
|
&& (time() - static::CACHE_TIMEOUT < $time)
|
||||||
|
|
Loading…
Reference in a new issue