Zend_Cache_Backend_Sqlite vs Zend_Cache_Backend_File

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 15:44:47

问题


Currently i'm using Zend_Cache_Backend_File for caching my project (especially responses from external web services). I was wandering if I could find some benefit in migrating the structure to Zend_Cache_Backend_Sqlite.

Possible advantages are:

  • File system is well-ordered (only 1 file in cache folder)
  • Removing expired entries should be quicker (my assumption, since zend wouldn't need to scan internal-metadatas for expiring date of each cache)

Possible disadvantages:

  • Finding record to read (with files zend check if file exists based on filename and should be a bit quicker) in term of speed.

I've tried to search a bit in internet but it seems that there are not a lot of discussion about the matter.

What do you think about it?

Thanks in advance.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2995679/zend-cache-backend-sqlite-vs-zend-cache-backend-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!