如何调整PHP Realpath缓存? [英] How can I tune the PHP realpath cache?
问题描述
最近版本的PHP都有一个文件名缓存,用于了解文件的真实路径,而require_once()
和include_once()
可以利用它.
Recent versions of PHP have a cache of filenames for knowing the real path of files, and require_once()
and include_once()
can take advantage of it.
您可以在 php.ini 中设置一个值来设置缓存的大小,但是我不知道如何确定大小.默认值为16k,但是我看不出要使用多少缓存.这些文档含糊不清:
There's a value you can set in your php.ini to set the size of the cache, but I have no idea how to tell what the size should be. The default value is 16k, but I see no way of telling how much of that cache we're using. The docs are vague:
确定realpath缓存的大小由PHP使用.在PHP打开许多文件的系统上,应该增加该值,以反映执行的文件操作的数量.
是的,我可以增加允许的缓存量,并使用ab
或其他测试来运行测试,但是我想要的是一些自省的功能,而不仅仅是从远处计时.
Yes, I can jack up the amount of cache allowed, and run tests with ab
or some other testing, but I'd like something with a little more introspection than just timing from a distance.
推荐答案
您可能已经发现了这一点,但是对于那些遇到此问题的人,可以使用realpath_cache_size()和realpath_cache_get()找出多少您的网站上正在使用realpath缓存,并相应地调整设置.
You've probably already found this, but for those who come across this question, you can use realpath_cache_size() and realpath_cache_get() to figure out how much of the realpath cache is being used on your site and tune the settings accordingly.
这篇关于如何调整PHP Realpath缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!