【问题标题】:PHP apc_store then apc_delete then apc_store returns a failurePHP apc_store 然后 apc_delete 然后 apc_store 返回失败
【发布时间】:2012-08-01 03:57:58
【问题描述】:

我是 php 新手并使用 APC 框架。我正在尝试为使用 APC 的类编写一些单元测试,但是我在尝试删除然后在 APC 中再次设置一些键值时遇到了一些问题。我的问题可以归结为一小部分代码没有按照我的预期工作:

$success = apc_store("helloWorld", 2, 0);  // true
$success1 = apc_delete("helloWorld");      // true
$success2 = apc_store("helloWorld", 3, 0); // false

此外,对 "helloWorld" 执行 fetch 调用将返回 NULL,并且我收到警告:

[apc-warning] 避免了键“helloWorld”的潜在缓存冲击

此外,我还尝试将其添加到我的 php.ini 文件中:

apc.enable_cli=ON

我还尝试将内存限制从默认的 32M 增加到 64M,方法是将其添加到我的 php.ini 文件中:

apc.shm_size = 64M

我在 Why would apc_store() return false? 上找到了这个相关问题,但没有一个建议对我有用。

如何解决这个问题,以便返回预期的三个 trues?为什么他们没有被退回?

【问题讨论】:

  • 第三行使用apc_add是否有效?
  • $success2 = apc_store("helloWorld", 3, 0); 替换为$success2 = apc_add("helloWorld", 3, 0); 仍然会导致success2 为假。
  • 请注意,我使用的是 APC 3.1.4 版

标签: php apc


【解决方案1】:

您的示例代码在 PHP 5.3.12 和 apc 3.1.9 中非常适合我 (true/true/true),所以也许您应该尝试更高版本?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-20
    • 2013-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-11
    • 1970-01-01
    相关资源
    最近更新 更多