2013-10-21 75 views
0

下面的memcached對象的大小在到達代碼末尾時會發生變化嗎?Memcached會在更新時減少對象的密鑰大小嗎?

<?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 ? 

?> 

回答

1

是的,它會減少內存使用memory_get_usage();

打印內存的使用情況,您將看到的尊重

$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 

嘗試在你的服務器

+0

銳利和很好的答案, 謝謝! – JLuiz