Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to check APC hit ratio?

Hi all,

Trying to implement and use the APC on Phalcon 3.0.1. Reading at the official documentation, the following sentence:

NOTE Even after implementing the cache, you should check the hit ratio of your cache over a period of time. This can easily be done, especially in the case of Memcache or Apc, with the relevant tools that the backends provide.

suggests there are tools for retrieving the hits on a key. While I can read it from the APC.php script available in the PHP distribution, I cannot get that value from Phalcon.

Do you know what methods the note is reffering to?

I would avoid APC. OPcache + PHP-FPM + nginx all the way. And libMemcached instead of APC*.

I think apc he ment only to use cache, so apcu most likely.

edited Apr '17

Thanks guys for your answers.

Actually I was searching for a native Phalcon method to read the hits. Even attempting to workaround it with the ->increment(), in getting the value, Phalcon gives the error reported in (need to stick with the 3.0.1 at the moment).

I would avoid APC. OPcache + PHP-FPM + nginx all the way. And libMemcached instead of APC*.

Memcache is a great solution but needs to rely on another running service; in addition, the performances are comparable. So, Jonathan Aaron, why you suggest to avoid APC*?

Anyway, the use case is to create a function that blocks requests. In particular, from the specifications, it needs to allow a maximum of 10 requests every 60 seconds (e.g. 10 request in the first second is fine, but then block all the further for the other 59 seconds).

Eventually, if someone is searching for the same thing, I workarounded saving hits and timestamp as array in cache, updating them accordingly. Possible better suggestions accepted.

edited Apr '17

Pretty much because apc need to comunicate between children and parent process in php-fpm but NOT in CLI.