1

我对 Judy Array 有奇怪的行为。文档只是说您可以像使用普通的 PHP 数组一样使用它。但无论我做什么,在我看来它都不会存储任何信息。

例如,如果我这样做:

$this->_history = new Judy(Judy::STRING_TO_MIXED);
$this->_history['test'] = 'testString';
echo $this->_history['test']; // output nothing; no warnings no text nothing
var_dump($this->_history); // class Judy#126 (0) { }
$this->_history->getType() // correctly (int) 5
$this->_history->getTypeFoo() // warning no method

难道我做错了什么?我是不是忘记了什么?我在 Ubuntu 和 Debian 系统上都对其进行了测试,两者都相同。

同样有趣的是,当我运行包中提供并在Judy Arraypecl下提取的 bench-script 时工作正常。/usr/share/php/doc/Judy/examples/judy-bench-string_to_int.php

这是我安装它的方法:

sudo aptitude install libjudydebian1 libjudy-dev
sudo pecl install judy

它说安装成功,我添加extension=judy.sophp.ini.
我应该怎么做才能让朱迪工作?

4

1 回答 1

1

好吧,现在可以了。但实际上我不知道为什么。我不应该在乎。bench-*.php我将文件中的工作代码从文件复制/docs到我自己的文件中,它可以工作。这是代码:

echo "\n-- Judy STRING_TO_INT \n";
echo "Mem usage: ". memory_get_usage() . "\n";
echo "Mem real: ". memory_get_usage(true) . "\n";

$s=microtime(true);
$judy = new Judy(Judy::STRING_TO_MIXED);
for ($i=0; $i<500; $i++)
    $judy["$i"] = 'test';
var_dump($judy);
unset($judy["102"]);
echo $judy["192"];
var_dump($judy["102"]);
echo "Size: ".$judy->size()."\n";
$e=microtime(true);
echo "Elapsed time: ".($e - $s)." sec.\n";
echo "Mem usage: ". memory_get_usage() . "\n";
echo "Mem real: ". memory_get_usage(true) . "\n";
echo "\n";

unset($judy);
于 2013-10-20T23:41:44.393 回答