【问题标题】:Will Memcached reduce the object's key size when it's updated?Memcached 在更新时会减小对象的密钥大小吗?
【发布时间】:2013-10-22 06:31:40
【问题描述】:

下面的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 ?

?>

【问题讨论】:

    标签: php architecture nosql memcached


    【解决方案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
    

    在你的服务器上试试

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-12
      • 1970-01-01
      • 1970-01-01
      • 2017-07-07
      • 1970-01-01
      • 2015-11-12
      相关资源
      最近更新 更多