Joseandro Luiz
Joseandro Luiz

Reputation: 9116

Will Memcached reduce the object's key size when it's updated?

Is the size of the following memcached object going to change when it reaches the end of the code?

<?php
$m = new Memcached();
$m->addServer('localhost', 11211);

$m->set('array', array(11, 12, 13, 14, 15, 16, 17, 18, 19, 20)); //Size in memory is X

$m->set('array', array(11, 12)); //Size in memory is ?

?>

Upvotes: 0

Views: 134

Answers (1)

Osama Jetawe
Osama Jetawe

Reputation: 2705

yes it will reduce the memory

print the usage of memory using memory_get_usage(); and you will see the deference

 $m->set('array', array(11, 12, 13, 14, 15, 16, 17, 18, 19, 20));

 $memory = memory_get_usage();
 echo $memory ."<br>"; // it print 235368

 $m->set('array', array(11, 12));

 $memory = memory_get_usage();
 echo $memory ."<br>"; // it print 235504

try it in your server

Upvotes: 1

Related Questions