Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
存在密钥时phpredis rpop返回false_Php_Redis_Phpredis - Fatal编程技术网

存在密钥时phpredis rpop返回false

存在密钥时phpredis rpop返回false,php,redis,phpredis,Php,Redis,Phpredis,我正在构建一个使用redis的游戏应用程序,这是我的php脚本 <?php //melon game pop //connect to redis db $redis = new Redis(); $redis->connect('127.0.0.1', 6379); //receive the data as json //$data = json_decode(file_get_contents('php://input'), true); $data = null;

我正在构建一个使用redis的游戏应用程序,这是我的php脚本

<?php
//melon game pop

//connect to redis db
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);


//receive the data as json
//$data = json_decode(file_get_contents('php://input'), true);
$data = null;


//decided to just grab the string
$key = file_get_contents('php://input');

//Shotgun debugging in action
$my_key = trim($key);

/*
 was originally sending json on reading into variables from array decided to simplify until my issue is resolved
//parse my data in to separate variables  
if ($data != null) {
$key = $data['key'];
//$value = $data['value'];  

//$key = utf8_decode($key);        
}
else
{
print "It's not recognizing your data!";
}
*/




$my_echo = $redis->rpop($my_key);

 //it returns false if the key doesn't exist, but i've shown that it clearly exists so  why is it returning false???

if ($my_echo == false) {

print $my_key;
//print '5'.$key;

//print "5failure";

}
else
{
print $my_echo;
}
?>
当我弹出“my_control”时,我从一个客户端获取{“key”:“\nubuntureft22”},然后使用浏览器从另一个客户端获取ubunturight22。当我从命令行手动弹出时,我得到以下信息:

redis-cli
127.0.0.1:6379> rpop my_control
"ubunturight22"
127.0.0.1:6379> rpop my_control
"{ \"key\": \"\\nubuntuleft23\" }"
127.0.0.1:6379> rpop "my_control"
"ubunturight23"
127.0.0.1:6379

尝试var_dump($my_echo)并检查键是否正确?我在$my_echo和$my_键上使用了var_dump,结果是:bool(false)字符串(13)“ubunturight20”,这正是我所期望的。除了双引号,但我猜这一定是var_dump()的函数?试试var_dump($redis->keys(“*”);在rpop之前,如果密钥是exits或notYes,则在按照指示执行操作时,我的密钥似乎不可见。
redis-cli
127.0.0.1:6379> rpop my_control
"ubunturight22"
127.0.0.1:6379> rpop my_control
"{ \"key\": \"\\nubuntuleft23\" }"
127.0.0.1:6379> rpop "my_control"
"ubunturight23"
127.0.0.1:6379