We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How Can I Specify a cache directory for a particular module within the application

I want to specify separate directories for cache in a multi-module application.

Thanks

edited Feb '15

Specify it in registerServices() or after routing subscribing to application:beforeStartModule, so:

// ...

$di['eventsManager']->attach('application:beforeStartModule', function (\Phalcon\Mvc\Application $app, $moduleName) use ($di) {
    $di->set('modelsMetadata', function () use ($moduleName) {
        return new \Phalcon\Mvc\Model\Metadata\Files([
            'metaDataDir' => APP_PATH . '/cahe/metadata/' . $moduleName
        ]);
    }, TRUE);
});


31.2k
Accepted
answer
edited Feb '15

It worked after doing the following:

in the config file;

'frontendcacheDir'       => __DIR__ . '\..\..\project\cache\frontend\frontend',

in the module class

$volt->setOptions(array(
                    'compiledPath' => $config->application->frontendcacheDir,
                    'compiledSeparator' => '_'
                ));