Zend_Cache_Backend_Sqlite vs Zend_Cache_Backend_File Zend_Cache_Backend_Sqlite vs Zend_Cache_Backend_File sqlite sqlite

Zend_Cache_Backend_Sqlite vs Zend_Cache_Backend_File


I'd say, it depends on your application.

Switch shouldn't be hard. Just test both cases, and see which is the best for you. No benchmark is objective except your own.

Measuring just performance, Zend_Cache_Backend_Static is the fastest one.


One other disadvantage of Zend_Cache_Backend_File is that if you have a lot of cache files it could take your OS a long time to load a single one because it has to open and scan the entire cache directory each time. So say you have 10,000 cache files, try doing an ls shell command on the cache dir to see how long it takes to read in all the files and print the list. This same lag will translate to your app every time the cache needs to be accessed.

You can use the hashed_directory_level option to mitigate this issue a bit, but it only nests up to two directories deep, which may not be enough if you have a lot of cache files. I ran into this problem on a project, causing performance to actually degrade over time as the cache got bigger and bigger. We couldn't switch to Zend_Cache_Backend_Memcached because we needed tag functionality (not supported by Memcached). Switching to Zend_Cache_Backend_Sqlite is a good option to solve this performance degradation problem.