如下的遍历方式效率是比较低的:
1. 因为是用的迭代的方式,所以内存使用很少
2. 迭代的过程如下,效率是非常地的:
sendto(3, "\310Q", 2, 0, NULL, 0) = 2 (continue)
recvfrom(3, "\0\0\0\0CTGT-MTI5NjI0OTk5MA==-130492"…, 65536, 0, NULL, NULL) = 72 (接收key)
sendto(3, "\3100\0\0\0CTGT-MTI5NjI0OTk5MA==-13049"…, 73, 0, NULL, 0) = 73 (get key)
recvfrom(3, "\0\0\0\0L{\"uid\":\"1296249990\",\"et\":13"…, 65536, 0, NULL, NULL) = 81 (接收value)
测试脚本:
- <?php
- $tt = new TokyoTyrant();
- $connected = $tt->connect($host, $port);
- $it = $tt->getIterator();
- foreach ($it as $key=>$val) {
- }