This topic created in 2111 days ago, the information mentioned may be changed or developed.
刚学 redis,环境 windows php,按照入门教程改了一下。
$redis->hSet("tutorial-name", "a", "1");
$redis->hSet("tutorial-name", "b", "2");
$data = $redis->hGetAll("tutorial-name");
var_dump($data);
结果是:boolean false
如果把 tutorial-name 换成其他字符是可以,咋回事啊?
6 replies • 2020-09-02 16:12:20 +08:00
 |
|
1
CEBBCAT Sep 2, 2020
https://documentation.help/php-redis/95153-10566-33069.html 提到: 执行如下的代码: $redis->delete('h'); $redis->hSet('h', 'a', 'x'); $redis->hSet('h', 'b', 'y'); $redis->hSet('h', 'c', 'z'); $redis->hSet('h', 'd', 't'); var_dump($redis->hGetAll('h')); 将会输出以下结果: array(4) { ["a"]=> string(1) "x" ["b"]=> string(1) "y" ["c"]=> string(1) "z" ["d"]=> string(1) "t" }
你的输出结果原文是什么?贴一段验证代码吧
|
 |
|
3
heybuddy Sep 2, 2020
``` <?php $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $redis->hSet("tutorial-name", "a", "1"); $redis->hSet("tutorial-name", "b", "2");
$data = $redis->hGetAll("tutorial-name"); print_r($data); ``` output: ``` Array ( [a] => 1 [b] => 2 ) ```
|
 |
|
4
Canon1014 Sep 2, 2020
emmmm,`keys *` 看看是不是 tutorial-name 已经存在了还是其他类型的
|
 |
|
6
pinews Sep 2, 2020
@ Canon1014 哈哈哈 是的 已经存在了,之前的 set get 随手改成了 hSet hGetAll 。 谢谢了各位。
|