V
V
Valery Chupurnov2016-03-09 10:08:59
PHP
Valery Chupurnov, 2016-03-09 10:08:59

Why is memcahce php dumping data?

I checked, I
connect like this

$mem = new Memcache();
$mem->connect('127.0.0.1', 11211);
$mem->set('test'.rand(10000000), rand(10000000), false, 600);
$stats = $mem->getStats();
echo 'Capacity: ' . round((real) $stats["bytes"]/(1024*1024), 3) . 'MB/' . round((real) $stats["limit_maxbytes"]/(1024*1024), 3) . ' MB';

The code works. until bytes reaches a certain value
Capacity: 18.798MB / 4098 MB this value is always different, from 10MB usually
Then a full reset. I don't use the flush method. Only write and read. Why does it behave like this? And isn't it better to switch to memcached?
Apache/2.2.31 (CentOS)
PHP/5.4.45
UPD
Checked code on memcached
<?php
$m = new Memcached;
$m->addServer('127.0.0.1', 11211);
if (!$m->get('key')) {    
    $m->set('key', 1);
    echo 'flush';
} else {
    var_dump($m->get('key'));
}

After 5-10 iterations, the reset is also complete. Under it, too, 4GB is allocated
UPD
Some success was achieved by making pconnect the connect place, i. use a persistent connection.
But then a full reset still happens, at least by 26MB, which is already much better, but still not that
UPD
As a result, we switched to Redis, the flight is normal

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nrt, 2016-03-09
@skoder

It's better to switch to Redis.

A
Alexander Aksentiev, 2016-03-09
@Sanasol

What is a full reset?
Then when is it?
You have a lifetime set for 10 minutes, after 10 minutes everything dies. What's wrong?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question