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?


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"

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.


What about set an empty key?


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] 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] 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.


Current version:

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