{"id":343719,"date":"2021-02-05T21:03:11","date_gmt":"2021-02-05T13:03:11","guid":{"rendered":"http:\/\/4563.org\/?p=343719"},"modified":"2021-02-05T21:03:11","modified_gmt":"2021-02-05T13:03:11","slug":"phpredis-%e7%9a%84%e8%ae%a2%e9%98%85%e6%a8%a1%e5%bc%8f%e7%96%91%e9%97%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=343719","title":{"rendered":"phpRedis \u7684\u8ba2\u9605\u6a21\u5f0f\u7591\u95ee"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  phpRedis \u7684\u8ba2\u9605\u6a21\u5f0f\u7591\u95ee               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xxbutoo <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6309\u7167\u6587\u6863\u4e0a\u7684 demo https:\/\/github.com\/phpredis\/phpredis#connect-open<\/p>\n<pre><code>function f($redis, $chan, $msg) {  switch($chan) {   case 'chan-1':    ...    break;    case 'chan-2':    ...    break;    case 'chan-2':    ...    break;  } }  $redis-&gt;subscribe(['chan-1', 'chan-2', 'chan-3'], 'f'); \/\/ subscribe to 3 chans```  \u4f46\u662f\u53d1\u5e03\u4ee5\u540e \u5c31\u4e00\u76f4\u6ca1\u6709\u8fd4\u56de\u503c\u4e86\u3002\u7b49\u4e86\u4e00\u4f1a\u540e\u5c31\u4f1a\u629b\u51fa read error on connection \u5f02\u5e38   \u67e5\u4e86\u8d44\u6599 subscribe \u662f\u963b\u585e\u6a21\u5f0f \u4e0d\u4f1a\u6709\u8fd4\u56de\u503c    \u4e8e\u662f\u6211\u8bbe\u7f6e\u4e86 <\/code><\/pre>\n<p>\/\/ ini_set(&#8216;default_socket_timeout&#8217;, -1);<\/p>\n<pre><code><\/code><\/pre>\n<p>\/\/ $redis-&gt;setOption($redis::OPT_READ_TIMEOUT, -1);<\/p>\n<pre><code> \u6267\u884c\u540e\u8fd4\u56de 502 \u4e86   \u8111\u74dc\u75bc cgi \u548c nginx \u53c8\u65ad\u5f00\u8fde\u63a5\u4e86\u3002\u3002<\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5295961\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ferock <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5e9f\u8bdd\u554a\uff0cfpm \u6a21\u5f0f\u4e0b\u600e\u4e48\u53ef\u80fd\u4e0d timeout \uff1f nginx \u4e5f\u4f1a timeout                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5295962\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ferock <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u60f3\u73a9\u8fd9\u4e2a\u53ea\u6709 cli \u6a21\u5f0f\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5295963\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : emeab <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bf7\u4f7f\u7528 php cli                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5295964\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : xxbutoo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ferock \u662f \u54e6\u662f\u54e6\u662f\u54e6\u662f\u54e6\uff01<br \/> \u6211\u641e\u50bb\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>phpRedis \u7684\u8ba2\u9605\u6a21\u5f0f\u7591\u95ee &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/343719"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343719"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/343719\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343719"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}