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 disable _PHCM(store all the keys) when using libmemcached?

Hello,

This is my first post on this forum, first of all thank you for the amazing project that is phalconphp.

I searched through the docs but couldn't find a way to disable PHCM when using libmemcached.

Is there any way to do this?

"This adapter uses the special memcached key “_PHCM” to store all the keys internally used by the adapter" http://docs.phalconphp.com/en/latest/api/Phalcon%5Cache%5Backend%5Libmemcached.html

Yes, but that would only change the name, i would like to disable that functionality so that no key will store a list of all the keys created.



83.4k
Accepted
answer

What about set an empty key?



987
Accepted
answer

Thank you very much, that worked!

I came across this same issue; setting the statsKey to be the empty string worked (meaning that Phalcon no longer reads/writes this enormous key to memcache), but it also causes the following errors to show up constantly:

[Fri May 29 16:48:07.883127 2015] [:error] [pid 3310] [client 172.45.0.79:43898] PHP Warning:  MemcachePool::get(): Invalid key in /srv/www/releases/20150528003722/app/library/Session/Adapter/Memcache.php on line 121
[Fri May 29 16:48:07.883314 2015] [:error] [pid 3310] [client 172.45.0.79:43898] PHP Warning:  MemcachePool::set(): Invalid key in /srv/www/releases/20150528003722/app/library/Session/Adapter/Memcache.php on line 121

All line 121 is doing is invoking Phalcon's memcache adapter. So the issue is that when the statsKey is the empty string, Phalcon still tries to read/write it from memcache, but the empty string is not a valid memcache key. There needs to be a correct way to simply disable this functionality; the _PHCM key grows and grows as we use more keys (we store session data in memcache) until it's several hundred KB, which means a huge performance hit from constantly reading/writing 500-1000kb of data to memcache.

edited Feb '16

This has been solved in latest 2.0.9.

Fix: https://github.com/phalcon/cphalcon/commit/b489cca3f63fcba8d1bb02b22e7d2cf2276cb7b5

Current version: https://github.com/phalcon/cphalcon/blob/master/phalcon/session/adapter/libmemcached.zep#L85

So, simply ommit the key in service definition, and that's it :) If you still provide the key, it will build that enormous array with all the keys... I'm nto sure what was the initial point in doing that.

EDIT: this is meant for SESSION adapter libmemcached, not for backend! So for session adaper just ommit statsKey. But for Cache backend - 'statsKey' => null //This is MANDATORY to be defined as null or empty string