We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Notice: MemcachePool::get(): Failed to unserialize data - Backend Memcache Cache

I know how Phalcon store data into cache when we fire $cache->save() method. It first serialize and then save date. But when we get data usign $cache->get(), it first data get and then unserialize. Now problem is phalcon does not check wheather it's integer value or string for unserialize ( as unserialize only apply for string ).

Now i store integer data into cache from other application and when i try to get this integer data from phalcon cache functions it gives me this error. Notice: MemcachePool::get(): Failed to unserialize data.

Is there any way to stop phalcon for unserialize data.

Override get() method?



145.0k
Accepted
answer

You need to use latest 3.0.x. You can compile it with zephir or wait for 3.0.2 version

edited Oct '16

You need to use latest 3.0.x. You can compile it with zephir or wait for 3.0.2 version

Yes i am using version 3.0.x

i just want to add one line that check if is_string() then unserialize else leave it. Can you tell me how i override just this line, or i need to re-define whole get() method.

Override get() method?

edited Oct '16

Then you don't installed it correctly. To install version 3.0.x you need to compile it with zephir. https://github.com/phalcon/cphalcon/blob/3.0.x/phalcon/cache/frontend/data.zep#L151 As you can see here, it's checking for numeric.

Regular PHP way. Extend parent class, then put a method with a same name, retain method's signature, and change inner logic to best fit your needs. Then call parent::methodName() if needed, or simply return new value of your processing.

i just want to add one line that check if is_string() then unserialize else leave it. Can you tell me how i override just this line, or i need to re-define whole get() method.

Override get() method?

edited Oct '16

But this is useless talk, the problem is fixed already. I marked my answer as solving it.