public function testSupports() { $this->assertNotNull($this->cache->supports()); $this->assertTrue($this->cache->supports('file')); $this->assertTrue($this->cache->supports('array')); $this->assertFalse($this->cache->supports('SomethingStupid')); }
public function register(Application $app) { $supports = Cache::supports(); foreach ($app['config']['cache'] as $name => $config) { $app[$name] = function () use($config, $supports) { if (!isset($config['storage'])) { throw new \RuntimeException('Cache storage missing.'); } if ($config['storage'] == 'auto' || !in_array($config['storage'], $supports)) { $config['storage'] = end($supports); } switch ($config['storage']) { case 'array': $storage = new ArrayCache(); break; case 'apc': $storage = new ApcCache(); break; case 'xcache': $storage = new XcacheCache(); break; case 'file': $storage = new FilesystemCache($config['path']); break; case 'phpfile': $storage = new PhpFileCache($config['path']); break; default: throw new \RuntimeException('Unknown cache storage.'); break; } $cache = new Cache($storage); if ($prefix = isset($config['prefix']) ? $config['prefix'] : false) { $cache->setNamespace($prefix); } return $cache; }; } }