Search code examples
phpapc

Detecting errors in apc


The php documentation describes how functions like apc_store return false if there is an error:

https://www.php.net/manual/en/function.apc-store.php

I'm curious what it means when there is an error, as I can't find any functions to actually return what the error was, or any documentation on why it would fail and return false.

Is there an equivalent to php's error_get_last for these apc return false functions? Or perhaps is error_get_last exactly what I'm looking for?

Thanks

Edit: actually the documentation says returns false on "failure", although I'm equally not sure what that means


Solution

  • The following conditions can cause apc_store to return false:

    • APC is disabled by configuration directive
    • Writing to the cache fails

    Writing to the cache can fail for the following reasons:

    • Shared memory is exhausted and or the SMA is busy (in garbage collection)
    • The key is being defended from slamming - you have set that key in the previous second from another process or thread

    APC does not set any global error numbers or strings upon failure, except, indirectly in those cases where the failure is due to an underlying syscall; don't rely on that.