質問

Using PHP, I'm persisting an array in memcached as part of the following process:

  1. Get array from memcached
  2. Perform operations on first item in array
  3. Update array based on result of operations
  4. Set array in memcached

The array contains URLs as strings.

The memcached set operation is failing for large array sizes. Most recently it failed for an array containing 78175 URLs.

The error I am getting from memcached is somewhat generic:

Result code: 10
Result message: SERVER ERROR

The libmemcached documentation is of little utility for this particular error.

The code I am using is quite straightforward:

public function save() {
    $this->memcached->set($this->key, $this->items);       
}    

protected function load() {
    $this->items = $this->memcached->get($this->key);        
    if (!$this->items) {
        $this->items = array();
    }
}


The libmemcached documention is of little immediate help for this error and the error itself is understandably vague.

What can be the causes for memcached error 10?

役に立ちましたか?

解決

Error is Memcached::OPT_BUFFER_WRITES - 10

$this->_Memcache =& new Memcached();
$this->_Memcache->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_PHP);
$this->_Memcache->setOption(Memcached::OPT_NO_BLOCK, true);
$this->_Memcache->setOption(Memcached::OPT_TCP_NODELAY, true);
$this->_Memcache->setOption(Memcached::OPT_BUFFER_WRITES, true);
$this->_Memcache->setOption(Memcached::OPT_SERVER_FAILURE_LIMIT,3);
$this->_Memcache->setOption(Memcached::OPT_HASH,Memcached::HASH_CRC);

他のヒント

In my case, I believe it was because the data exceeded the global maximum for a memcache object (1MB).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top