From 5de4a59d412aabb68a41aabdfea89547c65434be Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 8 Oct 2016 15:28:36 +0200 Subject: [PATCH] [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. --- index.php | 13 ++++++++----- lib/BridgeAbstract.php | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 43e777fe..6f447d92 100644 --- a/index.php +++ b/index.php @@ -117,11 +117,6 @@ try { // Data retrieval $bridge = Bridge::create($bridge); - $cache = Cache::create('FileCache'); - $cache->purgeCache(); - - $bridge->setCache($cache); - $noproxy = filter_input(INPUT_GET, '_noproxy', FILTER_VALIDATE_BOOLEAN); if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy){ define('NOPROXY',true); @@ -132,6 +127,14 @@ try { unset($params['bridge']); unset($params['format']); unset($params['_noproxy']); + + // Initialize cache + $cache = Cache::create('FileCache'); + $cache->purgeCache(); + $cache->setParameters($params); + + // Load cache & data + $bridge->setCache($cache); $bridge->setDatas($params); // Data transformation diff --git a/lib/BridgeAbstract.php b/lib/BridgeAbstract.php index 8ac633dd..95170996 100644 --- a/lib/BridgeAbstract.php +++ b/lib/BridgeAbstract.php @@ -138,7 +138,6 @@ abstract class BridgeAbstract implements BridgeInterface { */ public function setDatas(array $inputs){ if(!is_null($this->cache)){ - $this->cache->setParameters($inputs); $time = $this->cache->getTime(); if($time !== false && (time() - static::CACHE_TIMEOUT < $time)