Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何安装redis扩展 #17

Closed
yuzhanwaiting opened this issue Mar 4, 2015 · 1 comment
Closed

如何安装redis扩展 #17

yuzhanwaiting opened this issue Mar 4, 2015 · 1 comment

Comments

@yuzhanwaiting
Copy link

已经安装程序,并且能够正常运行。
使用redis扩展,使用 pecl上,phpredis 2.2.5
下面是关于redis存储数据,扩展编写

function set($key,$value,$ttl = 0)
{
$value = is_array($value) ? json_encode($value) : $value;
$this->handle->set($key,$value);
return $value;
}

function get($key,$use_cache = true)
{
    $value = $this->handle->get($key);

    $json = json_decode($value,true);

    return ($json == null) ? $value : $json;
}

启动程序是,一直报错
Invalid argument supplied for foreach() in /home/wwwroot/default/websocket/GatewayWorker/BusinessWorker.php on line 108

求解释,谢谢

@walkor
Copy link
Owner

walkor commented Apr 26, 2015

看起来是读到的数据不是个有效的数组,可能是序列化/反序列化的问题。
另外get代码不严谨,获取的数据一律反序列化,但是set时有时又不序列化。

请自行review && debug下代码吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants