Phosphorum\Bootstrap::initCache PHP Method

initCache() protected method

The frontend must always be Phalcon\Cache\Frontend\Output and the service 'viewCache' must be registered as always open (not shared) in the services container (DI).
protected initCache ( )
    protected function initCache()
    {
        $this->di->set('viewCache', function () {
            /** @var DiInterface $this */
            $config = $this->getShared('config');
            $frontend = new FrontOutput(['lifetime' => $config->get('viewCache')->lifetime]);
            $config = $config->get('viewCache')->toArray();
            $backend = '\\Phalcon\\Cache\\Backend\\' . $config['backend'];
            unset($config['backend'], $config['lifetime']);
            return new $backend($frontend, $config);
        });
        $this->di->setShared('modelsCache', function () {
            /** @var DiInterface $this */
            $config = $this->getShared('config');
            $frontend = '\\Phalcon\\Cache\\Frontend\\' . $config->get('modelsCache')->frontend;
            $frontend = new $frontend(['lifetime' => $config->get('modelsCache')->lifetime]);
            $config = $config->get('modelsCache')->toArray();
            $backend = '\\Phalcon\\Cache\\Backend\\' . $config['backend'];
            unset($config['backend'], $config['lifetime'], $config['frontend']);
            return new $backend($frontend, $config);
        });
        $this->di->setShared('dataCache', function () {
            /** @var DiInterface $this */
            $config = $this->getShared('config');
            $frontend = '\\Phalcon\\Cache\\Frontend\\' . $config->get('dataCache')->frontend;
            $frontend = new $frontend(['lifetime' => $config->get('dataCache')->lifetime]);
            $config = $config->get('dataCache')->toArray();
            $backend = '\\Phalcon\\Cache\\Backend\\' . $config['backend'];
            unset($config['backend'], $config['lifetime'], $config['frontend']);
            return new $backend($frontend, $config);
        });
    }