我刚刚开始使用 Predis 进行 Redis 迁移,但无法让 zadd 函数与数组一起使用。
此代码有效:
foreach ($userIndexArr as $row) {
$usernames[] = 0;
$usernames[] = $row['username'];
$result = $this->cache->zadd('@person', 0, $row['username']);
}
这不会:
foreach ($userIndexArr as $row) {
$usernames[] = 0;
$usernames[] = $row['username'];
}
try {
$result = $this->cache->zadd('@person', $usernames);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
并且不会抛出任何错误。任何帮助深表感谢!
-J