duansao20000508 2012-08-27 10:29
浏览 34
已采纳

APC操作码缓存如何识别类?

I'm running a one instance Apache setup with multiple virtual hosts that runs different versions of the same code base.

By this I mean that one virtual host can server one version of a class and another can server second version of the same class (same namespace, same name).

/file/path/host-a/MyClass.php
/file/path/host-b/MyClass.php

Sometimes I get an exception that shows me that one of the virtual hosts uses the "wrong" version of a class. E.g. on host b I get an exception with file path to script of /file/path/host-a/MyClass.php

I thought that the APC optcode cache used the file path, at least as a part of the key, but I'm fearing, that it only uses a qualified class name like:

My\Namespace\MyClass

Is that the case? Please point to any documentation on this subject if possible.

  • 写回答

1条回答 默认 最新

  • douke1942 2012-08-28 10:25
    关注

    Answer

    Though is was unable to find any documentation on the answer to this question php - APC opcode caching on different file versions explains that the APC optcode cache in fact does use the path of the file that defines the class to distinguis classes with the same name.

    Debugging

    After @hakra pointed out to me the behaviour of APC, I was able focus my efforts on the class loader. My class loader uses memcached as cache for storing the class paths. It turned out that the code for building cache keys were the cause of the problem - and not the APC which it seemed to be.

    So should you be in a similar situation where your see that the incorrect "versions" of a class is loaded ensure that you class loader is working as expected. One obvious clue is of course the file path of the problem class.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?