How to divide cache files into subdirectories?

Notice: This thread is very old.
Morfeo21
Member | 35
+
0
-

Hi,
I have an application which uses FileCache a lot … I mean, tens of thousands cache files in /temp/cache directory.

And in this amount of files it really slows down my server. I looked through FileStorage class, but I haven't found any setting how to divide cache files into more subdirectories.

Did anybody solve this problem? What can I do? Thanks for your help!

petr.pavel
Member | 535
+
0
-

The $namespace parameter to Cache constructor is used as a directory name.

$cache = Cache($storage, $namespace);
Morfeo21
Member | 35
+
0
-

Yep, I found this option. But I create Cache object in config.neon and it's passed via DI. So I have no option to change $namespace in each class which uses cache.

Milo
Nette Core | 1283
+
0
-

Inject only the Storage and create own Cache object (it is cheap). Or use

$subCache = $cache->derive('subfolder');
Morfeo21
Member | 35
+
0
-

Thanks,

$cache->derive('folder');

is exactly what I was looking for :)