REDIS使用“ GET post:*-> price”排序时返回空值

时间:2019-06-14 00:46:55

标签: php mysql database redis

我有一个PHP脚本,该脚本处理REDIS以添加和获取数据:

$redis->hmset("post:1000", "product", "Red Shoes", "price", "5USD", "quantity", "2", "time", "02/02/2019");
$redis->hmset("post:2000", "product", "Yellow Shoes", "price", "5USD", "quantity", "2", "time", "02/02/2019");
$redis->hmset("post:3000", "product", "Pink Shoes", "price", "5USD", "quantity", "2", "time", "02/02/2019");
$redis->sadd("All_keys", array("post:1000", "post:2000", "post:3000"));

$key = "All_keys";
$keys = $redis->sort($key, array(
    'by' => 'nonsort',
    'get' => "post:*->price"
));

var_dump($keys);

但是不幸的是,这个回报:

array(3) { [0]=> NULL [1]=> NULL [2]=> NULL }

但是当我更改此设置时:

$keys = $redis->sort($key, array(
    'by' => 'nonsort',
    'get' => "post:*->price"
));

收件人:

$keys = $redis->sort($key, array(
    'by' => 'nonsort',
    'get' => "*->price"
));

这将正常返回价格:

array(3) { [0]=> string(4) "5USD" [1]=> string(4) "5USD" [2]=> string(4) "5USD" }

请问这种模式有什么问题?

post:*->price

由于我在那里看不到任何错误,因此应该能很好地工作。

欢迎您的帮助,谢谢。

0 个答案:

没有答案