php - Predis 上 BLPOP 的正确语法是什么?

标签 php syntax redis

我是这样做的:

$r = new Predis\Client($single_server, $options);
$retval = $r->blpop('queue:query');

但是我得到这个错误:

ERR 'blpop' 命令的参数数量错误

每当我这样做时

$r = new Predis\Client($single_server, $options);
$retval = $r->blpop('queue:query',0);

我得到错误:

从服务器读取行时出错

redis-cli 执行它

redis 127.0.0.1:6379> BLPOP queue:query
(error) ERR wrong number of arguments for 'blpop' command
redis 127.0.0.1:6379> BLPOP queue:query 0
1) "queue:query"
2) "hello world"

最佳答案

似乎是一个错误。 latest版本没有这个问题,它显然也删除了命名空间:

<?
include_once "Predis.php";

$r = new Predis_Client();
$retval = $r->blpop('queue:query',0);
var_dump($retval);
?> 

当我访问该页面时它被阻止了。然后,我发出了 LPUSH queue:query 0,回到页面,得到了这个:

array(2) { [0]=> string(11) "queue:query" [1]=> string(1) "0" }

尽管如此,我还是推荐使用 phpredis ,它比这个库更快,因为它被编译为 php 扩展。如果您拥有服务器的权限,那是个不错的选择。

关于php - Predis 上 BLPOP 的正确语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7578016/

相关文章:

set - 清空/删除 Redis 中的集合?

php - 在 Linux 上升级 PHP 版本 5.6 -> 7 个问题

php - 如何使用 PHP 更改 Excel 单元格日期格式

java - 反编译后的一些语法问题

syntax - 零件和跨度 : is there a reason this *should* not work?

xcode - Swift - 闭包表达式语法

javascript - PHP/Javascript - 使用 Stripe API 添加付款方式

php - 显示时间 :minutes:seconds:milliseconds in php

c# - 如何使用 C# 在 Redis 中添加对象列表作为键的值?

php - 使用非零的数据库编号时,Laravel 6 redis session 不存储到 redis