Does the symfony cache file system handle ext2 32000 files in the same directory limitation?
문제
Does the symfony cache system handle ext2 32000 files in the same directory limitation ?
I have 80000 users and i want to cache their profiles but do symfony cache system handle the ext2 limitation ?
i'm also posting for the others who will face the same problem.
해결책
I'm not 100% sure whether my answer is correct but in PROJECT/lib/symfony/cache/sfCacheFile.class.php
there is a method: sfCacheFile::getFilePath()
that returns a path to a file. It seems that there is no any protection against limitations of ext2
filesystem.
But there is a very simple solution - override that class:
In
PROJECT/apps/APP/config/factories.yml
set your own cache class:default: # Others factories (if any) view_cache: class: myOwnFileCache param: automatic_cleaning_factor: 0 cache_dir: %SF_TEMPLATE_CACHE_DIR% lifetime: 86400 prefix: %SF_APP_DIR%/template
Now create that class and make sure it extends
sfFileCache
and overridesgetFilePath()
# PROJECT/lib/PROJECT/cache/myOwnFileCache.class.php class myOwnFileCache extends sfFileCache { protected getFilePath($key) { /* Convert from: abcdef to: a/b/abcdef */ $key = substr($key, 0, 1) . DIRECTORY_SEPARATOR . substr($key, 1, 1) . DIRECTORY_SEPARATOR . $key; return parent::getFilePath($key); }
}
Clear cache:
./symfony cc
Now you need 32000 cache keys that starts with the exact same two letters/digits to crush your filesystem.