4

Every time I try to use the add() function for memcached, I get the following error:

A PHP Error was encountered

Severity: Warning

Message: MemcachePool::add(): The lowest two bytes of the flags array is reserved for pecl/memcache internal use

Filename: libraries/memcached_library.php

Line Number: 92

What could be wrong? I'm using this library for codeigniter: http://github.com/trs21219/memcached-library

4 Answers 4

14

Are you on 64 bits? It looks like it's a recently found bug with pecl/memcache: http://pecl.php.net/bugs/bug.php?id=18567

It seems like it has to do with the compression flag. It can't be a boolean anymore, it needs to be an integer according to this source code

/**
 * The compressed argument on Memcache::add, Memcache::set and Memcache::replace takes
 * an integer not a boolean. Since pecl/memcache 3.0.3 booleans now leads to warnings like
 * The lowest two bytes of the flags array is reserved for pecl/memcache internal use
 */
Sign up to request clarification or add additional context in comments.

2 Comments

Perfect. Thanks. I changed compression from TRUE to 0 and everything works fine now.
I was using Memcache on windows and facing the same issue. Just to repeat, 'Compression' will be the third argument if passes which need to be 0 to resolve it. Ref:php.net/manual/en/memcache.set.php
7

May be it's your case: some manuals for memcache using, like http://www.codeforest.net/how-to-install-memcached-on-windows-machine, have a mistake:

$memcache->add("key", $tmp, 30);

but correct use of expiration seconds parameter (30 sec here) is:

$memcache->add("key", $tmp, MEMCACHE_COMPRESSED, 30);

or like

$memcache->add("key", $tmp, false, 30);

Sample of manual with correct example: http://zurmo.org/wiki/installing-memcache-on-windows
See also documentation http://php.net/manual/ru/memcache.add.php

For me it was the key.

Comments

5

You can add 'false' as the third parameter, it worked for me.

Warning (2): MemcachePool::add() [memcachepool.add]: The lowest two bytes of the flags array is reserved for pecl/memcache internal use

From:
return $this->memcache->add($name, $value, $expiry);

To:
return $this->memcache->add($name, $value, false, $expiry);

1 Comment

Yes, Memcache and Memcached methods in the PHP are differs
1

This might be helpful for some, I had downloaded a library for codeigniter that made use of memcache not memcached for sessions. It can be found here: https://github.com/pierskarsenbarg/codeigniter-session-memcached

The problem for me was that when the lib was using

memcache->set()

and/or

memcache->replace()

the third parameter was the expire time and not a valid flag type.

i.e. MEMCACHE_COMPRESSED

Example

Original Code:

$this->memcache->set('user_session_data' . $this->userdata['session_id'], $this->userdata, $this->sess_expiration); 

Changed Code:

$this->memcache->set('user_session_data' . $this->userdata['session_id'], $this->userdata, MEMCACHE_COMPRESSED, $this->sess_expiration);

After changing the third parameter to a correct flag type the error went away.

1 Comment

You answered in fact just the same I do upper, but about codeigniter memcached feature bug. I think it's useful too - upvote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.