Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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);
});


15.1k
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' => '_'
                ));