public function __construct($noContainerCache = false) { $this->root = $this->root(); $cache = new Cache($this->root); $this->environment(); $this->errors(); $this->apiToken = $this->apiTokenFromRequest(); $items = ['collections', 'forms', 'bundles', 'topics', 'routes', 'container', 'languages', 'config']; $person = false; if (!empty($this->apiToken)) { $person = json_decode($cache->get('person-' . $this->apiToken), true); } $cacheResult = json_decode($cache->get($this->cachePrefix . '-opine'), true); $containerCache = []; if ($noContainerCache === false && isset($cacheResult['container'])) { $containerCache = $cacheResult['container']; } if ($cacheResult['routes'] != false) { $this->routeCached = true; } $config = new Config($this->root); if ($cacheResult['config'] !== false) { $configData = $cacheResult['config']; if (isset($configData[$this->environment])) { $config->cacheSet($configData[$this->environment]); } elseif (isset($configData['default'])) { $config->cacheSet($configData['default']); } } else { $config->cacheSet(); } $this->container = Container::instance($this->root, $config, $this->root . '/../config/containers/container.yml', $noContainerCache, $containerCache); $this->container->set('cache', $cache); $this->cache($cacheResult, $person); }
public function __construct($noContainerCache = false) { $this->environment(); $this->errors(); $this->root = $this->root(); $this->apiToken = $this->apiTokenFromRequest(); $items = [$this->root . '-collections' => false, $this->root . '-forms' => false, $this->root . '-bundles' => false, $this->root . '-topics' => false, $this->root . '-routes' => false, $this->root . '-container' => false, $this->root . '-languages' => false, $this->root . '-config' => false]; if (!empty($this->apiToken)) { $items['person-' . $this->apiToken] = false; } $cache = new Cache(); $cacheResult = $cache->getBatch($items); $containerCache = []; if ($noContainerCache === false && isset($items[$this->root . '-container'])) { $containerCache = json_decode($items[$this->root . '-container'], true); } if ($items[$this->root . '-routes'] != false) { $this->routeCached = true; } $config = new Config($this->root); if ($items[$this->root . '-config'] !== false) { $configData = json_decode($items[$this->root . '-config'], true); if (isset($configData[$this->environment])) { $config->cacheSet($configData[$this->environment]); } elseif (isset($configData['default'])) { $config->cacheSet($configData['default']); } } else { $config->cacheSet(); } $this->container = Container::instance($this->root, $config, $this->root . '/../config/containers/container.yml', $noContainerCache, $containerCache); $this->container->set('cache', $cache); $this->cache($items); }
public function testDeleteBatch() { $cache = new Cache(self::ROOT); $items = ['phpunit-test', 'phpunit-test2']; $this->assertTrue($cache->deleteBatch($items)); $this->assertFalse($cache->get('phpunit-test')); $this->assertFalse($cache->get('phpunit-test2')); }