From 9606c7ed99826875ed21e9b4a61a5958055e8e93 Mon Sep 17 00:00:00 2001 From: Tom Butler Date: Mon, 14 May 2018 17:33:46 +0100 Subject: [PATCH] removed old file --- src/SheetCache.php | 60 ---------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 src/SheetCache.php diff --git a/src/SheetCache.php b/src/SheetCache.php deleted file mode 100644 index ed3ed2e..0000000 --- a/src/SheetCache.php +++ /dev/null @@ -1,60 +0,0 @@ - | https://r.je/ * - * @license http://www.opensource.org/licenses/bsd-license.php BSD License * - * @version 1.2 */ -namespace Transphporm; -//Separates out TSS file loading/caching from parsing -class SheetCache { - private $cacheKey; - private $cacheName; - private $cache; - - public function __construct(Cache $cache) { - $this->cache = $cache; - } - - private function getRulesFromCache($file) { - //Try to load the cached rules, if not set in the cache (or expired) parse the supplied sheet - $rules = $this->cache->load($this->cacheName, filemtime($file)); - - $this->cacheKey = $this->cacheKey ?? $rules['cacheKey'] ?? null; - - if ($rules) { - foreach ($rules['import'] as $file) { - //Check that the import file hasn't been changed since the cache was written - if (filemtime($file) > $rules['ctime']) return false; - } - } - return $rules; - } - - public function getCacheKey($tss, $data) { - //Read the rules so that $this->cacheKey is set - if (is_file($tss)) $this->getRulesFromCache($tss); - if ($this->cacheKey) { - $parser = new Parser\Value($data); - $parsedKey = $parser->parseTokens($this->cacheKey)[0]; - $this->cacheName = $parsedKey . $this->tss; - return $parsedKey; - } - else return ''; - } - - - //write the sheet to cache - public function write($file, $rules, $imports = []) { - if (is_file($file)) { - $existing = $this->cache->load($file, filemtime($file)); - if (isset($existing['import'])) $imports = $existing['import']; - $this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]); - } - return $rules; - } - - public function setKey($key) { - $this->cacheKey = $key; - } - -} \ No newline at end of file