【发布时间】:2012-01-24 21:03:18
【问题描述】:
我正在尝试调整我的缓存,在进行基准测试时,我发现了一些让我很困惑的东西。
从我的远程 Memcached 盒子(本地网络)中提取一个密钥需要 0.0008 秒,而从我的本地 APC 缓存中提取一个密钥需要 0.0114 秒。是的,它快了整整 14 倍。
这对于本地缓存来说似乎非常慢...我应该调整哪些设置以使其更有效?
编辑:根据要求,这是我在 php.ini 中的 APC 配置
[APC]
;specifies the size for each shared memory segment will need adjustment for your environment.
apc.shm_size=8
;max amount of memory a script can occupy
apc.max_file_size=1M
apc.ttl=0
apc.gc_ttl=3600
; means we are always atomically editing the files
apc.file_update_protection=0
apc.enabled=1
apc.enable_cli=0
apc.cache_by_default=1
apc.include_once_override=0
apc.localcache=0
apc.localcache.size=512
apc.num_files_hint=1000
apc.report_autofilter=0
apc.rfc1867=0
apc.slam_defense=0
apc.stat=1
apc.stat_ctime=0
apc.ttl=7200
apc.user_entries_hint=4096
apc.user_ttl=7200
apc.write_lock=1
通过一个简单的 apc_fetch('my_key'); 完成获取
【问题讨论】:
-
您可能希望包含您的 APC 配置和获取代码
-
如果每次都未命中,那么它总是比缓存慢。