How set dynamic viewCache dir?

I config a cache dir like: ```php $di->set('viewCache', function () use ($config) {

$frontendOptions = array(
    'lifetime' => $config->cache->html->lifetime
);

//Create a output cache
$frontCache = new FrontOutput($frontendOptions);

//Set the cache directory
$backendOptions = array(
    'cacheDir' => $config->cache->html->dir
);

//Create the File backend
$cache = new \Phalcon\Cache\Backend\File($frontCache, $backendOptions);

return $cache;

});

``` but will be a lot of saved files in one directory. Need put them on sub dirs by the hash. For example: cacheDir/aa/ cacheDir/ab/ cacheDir/ac/ ...

What do you need the sub dirs for? its a caceh directory as it is not ever meant to be viewed. its just there to speed up render times.

If you are doing frontend/backend you might consider multimodule. you can set a cache dir for each app.

$di->setShared('view', function () use ($config) {
    $view = new View();
    $view->setViewsDir($config->application->viewsDir);
    $view->registerEngines(array(
        '.volt' => function ($view, $di) use ($config) {
            $volt = new VoltEngine($view, $di);
            $volt->setOptions(array(
                'compiledPath' => $config->application->cacheDir,
                'compiledSeparator' => '_'
            ));
            return $volt;
        }
    ));
    return $view;
});


5.9k

I have not a multimodule and this is a standart of filecaching.

For example, ext3 can have many thousands of files; but after a couple of thousands, it used to be very slow. Mostly when listing a directory, but also when opening a single file. A few years ago, it gained the 'htree' option, that dramatically shortened the time needed to get an inode given a filename. see stackoverflow.com.