{"id":79,"date":"2019-11-07T15:15:22","date_gmt":"2019-11-07T07:15:22","guid":{"rendered":"http:\/\/blog.yuekegu.com\/?p=79"},"modified":"2019-11-07T15:15:22","modified_gmt":"2019-11-07T07:15:22","slug":"yii2-%e9%85%8d%e7%bd%aeyii2-redis%e6%89%a9%e5%b1%95","status":"publish","type":"post","link":"https:\/\/book.yuekegu.com\/index.php\/2019\/11\/07\/yii2-%e9%85%8d%e7%bd%aeyii2-redis%e6%89%a9%e5%b1%95\/","title":{"rendered":"Yii2 \u914d\u7f6eyii2-redis\u6269\u5c55"},"content":{"rendered":"\n<p>Yii2-redis \u4e0d\u7528 composer \u7684\u5b89\u88c5<br>\u7531\u4e8e composer \u662f\u56fd\u5916\u7684\u6e90\uff0c\u6240\u4ee5\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u5f88\u96be\u6210\u529f<br>php composer.phar require &#8211;prefer-dist yiisoft\/yii2-redis<\/p>\n\n\n\n<p>\u6539\u6210\u624b\u52a8\u5b89\u88c5redis<br>1\u3001\u4e0b\u8f7d yii2-redis \u7684\u6587\u4ef6<br>https:\/\/github.com\/yiisoft\/yii2-redis\/archive\/master.zip<br>\u6539\u6587\u4ef6\u5939\u540d\u4e3a yii2-redis\uff0c\u653e\u5230 vendor\\yiisoft \u76ee\u5f55\u4e0b<\/p>\n\n\n\n<p>2\u3001\u7f16\u8f91\u6587\u4ef6vendor\\yiisoft\\extensions.php\uff1a<br>&#8216;yiisoft\/yii2-redis&#8217; =>   <br>     \u3000\u3000array (  <br>        \u3000\u3000\u3000\u3000&#8217;name&#8217; => &#8216;yiisoft\/yii2-redis&#8217;,  <br>        \u3000\u3000\u3000\u3000&#8217;version&#8217; => &#8216;2.0.14.0&#8217;,  <br>        \u3000\u3000\u3000\u3000&#8217;alias&#8217; =>   <br>        \u3000\u3000\u3000\u3000\u3000\u3000array (  <br>          \u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000&#8217;@yii\/redis&#8217; => $vendorDir . &#8216;\/yiisoft\/yii2-redis\/src&#8217;,  <br>        \u3000\u3000\u3000\u3000\u3000\u3000),  <br>     \u3000\u3000),  <\/p>\n\n\n\n<p>3\u3001\u7f16\u8f91\u6587\u4ef6vendor\\composer\\autoload_psr4.php\uff0c\u52a0\u5165\uff1a<br>&#8216;yii\\\\redis\\\\&#8217; =&gt; array($vendorDir . &#8216;\/yiisoft\/yii2-redis\/src&#8217;),<\/p>\n\n\n\n<p>4\u3001\u7f16\u8f91\u6587\u4ef6 main.php<br>return [<br>    \u3000\u3000\/\/&#8230;.<br>    \u3000\u3000&#8217;components&#8217; =&gt; [<br>        \u3000\u3000\u3000\u3000&#8217;redis&#8217; =&gt; [<br>            \u3000\u3000\u3000\u3000\u3000\u3000&#8217;class&#8217; =&gt; &#8216;yii\\redis\\Connection&#8217;,<br>            \u3000\u3000\u3000\u3000\u3000\u3000&#8217;hostname&#8217; =&gt; &#8216;localhost&#8217;,<br>            \u3000\u3000\u3000\u3000\u3000\u3000&#8217;port&#8217; =&gt; 6379,<br>            \u3000\u3000\u3000\u3000\u3000\u3000&#8217;database&#8217; =&gt; 0,<br>        \u3000\u3000\u3000\u3000],<br>    \u3000\u3000]<br>];<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yii2-redis \u4e0d\u7528 composer \u7684\u5b89\u88c5\u7531\u4e8e composer \u662f\u56fd\u5916\u7684\u6e90\uff0c\u6240\u4ee5\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u5f88\u96be\u6210\u529fphp composer.phar require &#8211;prefer-dist yiisoft\/yii2-redis \u6539\u6210\u624b\u52a8\u5b89\u88c5redis1\u3001\u4e0b\u8f7d yii2-redis \u7684\u6587\u4ef6https:\/\/github.com\/yiisoft\/yii2-redis\/archive\/master.zip\u6539\u6587\u4ef6\u5939\u540d\u4e3a yii2-redis\uff0c\u653e\u5230 vendor\\yiisoft \u76ee\u5f55\u4e0b 2\u3001\u7f16\u8f91\u6587\u4ef6vendor\\yiisoft\\extensions.php\uff1a&#8216;yiisoft\/yii2-redis&#8217; => \u3000\u3000array ( \u3000\u3000\u3000\u3000&#8217;name&#8217; => &#8216;yiisoft\/yii2-redis&#8217;, \u3000\u3000\u3000\u3000&#8217;version&#8217; => &#8216;2.0.14.0&#8217;, \u3000\u3000\u3000\u3000&#8217;alias&#8217; => \u3000\u3000\u3000\u3000\u3000\u3000array ( \u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000&#8217;@yii\/redis&#8217; => $vendorDir . &#8216;\/yiisoft\/yii2-redis\/src&#8217;, \u3000\u3000\u3000\u3000\u3000\u3000), \u3000\u3000), 3\u3001\u7f16\u8f91\u6587\u4ef6vendor\\composer\\autoload_psr4.php\uff0c\u52a0\u5165\uff1a&#8216;yii\\\\redis\\\\&#8217; =&gt; array($vendorDir . &#8216;\/yiisoft\/yii2-redis\/src&#8217;), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,18],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-redis","category-yii2"],"_links":{"self":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":0,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"wp:attachment":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}