PHP APC: What happens when APC cache is full?

亡梦爱人 提交于 2019-12-30 08:01:47

问题


What happens when you try to add a variable into APC and the APC cache is full? Does it automatically remove least used variable from the cache?


回答1:


According to APC: Runtime Configuration, "In the event of a cache running out of available memory, the cache will be completely expunged if ttl is equal to 0. Otherwise, if the ttl is greater than 0, APC will attempt to remove expired entries."

So if there is a non-zero TTL, it will remove entries whose time to live has passed. ;) Otherwise, it will remove the entire cache.

I notice this doesn't really address what happens if the cache runs out of memory and you have an excessively high TTL.




回答2:


From experience (we run it in production), if you do not set a TTL or the TTL is very very high and nothing is out of date, the entire cache is flushed (as in made empty). You really want to try and avoid this as it will cause a load spike on the next request that PHP has to deal with, becuase for every file needed APC will need to compile it and store it in memory (which as a slightly slower process than not having a cache enabled at all). Also if you are recieving lots of traffic and empty cache, you will experience cache slam (see google for the evilness of this)

As a side note, see this old presentation for a fairly rough guide to APC and things to watch out for http://www.slideshare.net/oscon2007/os-gopal Somethings maybe out of date in it but the theory still holds true.



来源:https://stackoverflow.com/questions/1053810/php-apc-what-happens-when-apc-cache-is-full

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