memcached not storing array of complex items with specific keys


2 weeks ago


10 time


Somehow I can't store an array of complex items if i put user_ as prefix in the key

my php code

  $this->skills = [
            'defensiv' => DefensivSkill::getAllUserSkills($this),
            'offensiv' => OffensivSkill::getAllUserSkills($this),
            'spezial'  => SpezialSkill::getAllUserSkills($this),
            'pve'      => PVESkill::getAllUserSkills($this)
        $_MEMCACHED->set('user_'.$this->getUserId().'_skills', $this->skills); //is not stored
        $_MEMCACHED->set($this->getUserId().'_skills', $this->skills); //is stored

I call getAllKeys() after this and check if its stored... I thought about the key length, but thats not the problem. After checking the key is 30 chars long - but I already have keys which are 39 chars long.

$_MEMCACHED = new Memcached();
$_MEMCACHED->addServer('localhost', 11212);
$_MEMCACHED->setOption(Memcached::OPT_PREFIX_KEY, 'hogsmeade_');

this is my connector, the MemCached Server runs with 4GB total limit, and 256mb Item limit. The classes of the object implements serializable. memcached is compiled with igbinary support

Memcached v1.4.25 php-memcached v3.0.3 lib_memcached 1.0.18

** EDIT ** the serialized array $this->skills is ~4500chars long (var_dump())

** EDIT 2 **

$_MEMCACHED->set('cache_user_'.$this->getUserId().'_skills', $this->skills);

works - only fails if i start the key with user_

I did also extend memcached to track if I delete it somewhere

class MyMemcached extends Memcached
public function delete($key, $time = 0)
    file_put_contents(ROOT.'/memcache.log', 'DELETE '.$key, FILE_APPEND);
    parent::delete($key, $time); // TODO: Change the autogenerated stub

public function deleteMulti(array $keys, $time = 0)
    file_put_contents(ROOT.'/memcache.log', 'DELETE '.json_encode($keys), FILE_APPEND);
    parent::deleteMulti($keys, $time); // TODO: Change the autogenerated stub

but i dont

0 answers