{"id":1648,"date":"2023-03-25T21:48:09","date_gmt":"2023-03-25T13:48:09","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1648"},"modified":"2023-04-23T21:57:21","modified_gmt":"2023-04-23T13:57:21","slug":"magento-using-redis","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/magento-using-redis\/","title":{"rendered":"Magento\u4f7f\u7528Redis"},"content":{"rendered":"<p>M2\u9ed8\u8ba4\u5c06\u6570\u636e\u7f13\u5b58\u3001\u5168\u9875\u7f13\u5b58\u3001session\u4fdd\u5b58\u5728\u4ee5\u4e0b\u4e09\u4e2a\u76ee\u5f55<\/p>\n<pre><code>var\/cache\nvar\/page_cache\nvar\/session<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u4e5f\u652f\u6301\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\uff0c\u5c06\u4ee5\u4e0a\u6570\u636e\u5b58\u653e\u5230Redis<\/p>\n<h3>\u5b89\u88c5redis<\/h3>\n<pre><code>yum -y install redis<\/code><\/pre>\n<h3>\u542f\u52a8redis<\/h3>\n<pre><code>\/usr\/bin\/redis-server \/etc\/redis.conf<\/code><\/pre>\n<p>\u542f\u52a8<code>redis-server<\/code>\u524d\uff0c\u5148\u4f7f\u7528vim\u6253\u5f00\u914d\u7f6e\u6587\u4ef6<code>\/etc\/redis.conf<\/code><br \/>\n\u627e\u5230<code>daemonize no<\/code>\uff0c\u6539\u4e3a<code>yes<\/code>\uff0c\u5426\u5219\u542f\u52a8\u540e\uff0c\u4f1a\u4e00\u76f4\u5360\u7528\u754c\u9762<\/p>\n<h3>M2\u914d\u7f6e<\/h3>\n<p>\u6253\u5f00<code>app\/etc\/env.php<\/code>\uff0c\u627e\u5230\u7c7b\u4f3c\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-php\">    &#039;session&#039; =&gt; [\n        &#039;save&#039; =&gt; &#039;files&#039;\n    ],\n    &#039;cache&#039; =&gt; [\n        &#039;frontend&#039; =&gt; [\n            &#039;default&#039; =&gt; [\n                &#039;id_prefix&#039; =&gt; &#039;f37_&#039;\n            ],\n            &#039;page_cache&#039; =&gt; [\n                &#039;id_prefix&#039; =&gt; &#039;f37_&#039;\n            ],\n            &#039;allow_parallel_generation&#039; =&gt; false\n        ],\n    ],<\/code><\/pre>\n<p>\u4fee\u6539\u4e3a\uff1a<\/p>\n<pre><code class=\"language-php\">    &#039;session&#039; =&gt; [\n        &#039;save&#039; =&gt; &#039;redis&#039;,\n        &#039;redis&#039; =&gt; [\n            &#039;host&#039; =&gt; &#039;127.0.0.1&#039;,\n            &#039;port&#039; =&gt; &#039;6379&#039;,\n            &#039;database&#039; =&gt; &#039;2&#039;,\n        ]\n    ],\n    &#039;cache&#039; =&gt; [\n        &#039;frontend&#039; =&gt; [\n            &#039;default&#039; =&gt; [\n                &#039;backend&#039; =&gt; &#039;Cm_Cache_Backend_Redis&#039;,\n                &#039;backend_options&#039; =&gt; [\n                    &#039;server&#039; =&gt; &#039;127.0.0.1&#039;,\n                    &#039;port&#039; =&gt; &#039;6379&#039;,\n                    &#039;database&#039; =&gt; &#039;0&#039;\n                ]\n            ],\n            &#039;page_cache&#039; =&gt; [\n                &#039;backend&#039; =&gt; &#039;Cm_Cache_Backend_Redis&#039;,\n                &#039;backend_options&#039; =&gt; [\n                    &#039;server&#039; =&gt; &#039;127.0.0.1&#039;,\n                    &#039;port&#039; =&gt; &#039;6379&#039;,\n                    &#039;database&#039; =&gt; &#039;1&#039;\n                ]\n            ],\n            &#039;allow_parallel_generation&#039; =&gt; false\n        ],\n    ],<\/code><\/pre>\n<h3>\u6d4b\u8bd5<\/h3>\n<pre><code>rm -rf cache\/* page_cache\/* session\/*<\/code><\/pre>\n<p>\u5220\u9664\u4e0a\u6587\u63d0\u53ca\u7684\u4e09\u4e2a\u76ee\u5f55\u7684\u6587\u4ef6\uff0c\u7136\u540e\u8bbf\u95ee\u7f51\u7ad9\uff0c\u7f51\u7ad9\u6b63\u5e38\u8bbf\u95ee\u3002\u518d\u6b21\u67e5\u770b\u8fd9\u4e09\u4e2a\u76ee\u5f55\uff0c\u53d1\u73b0\u4e0d\u518d\u751f\u6210\u65b0\u7684\u6587\u4ef6\u4e86\u3002<br \/>\n\u67e5\u770bRedis\uff0c\u7ed3\u679c\u5982\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/PHP\/Magento-Redis-Data.png\" alt=\"Magento-Redis-Data\" \/><\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u5c31\u5c06M2\u7684\u7f13\u5b58\u4ece\u6587\u4ef6\u5207\u6362\u5230Redis\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>M2\u9ed8\u8ba4\u5c06\u6570\u636e\u7f13\u5b58\u3001\u5168\u9875\u7f13\u5b58\u3001session\u4fdd\u5b58\u5728\u4ee5\u4e0b\u4e09\u4e2a\u76ee\u5f55 var\/cache var\/page_cach [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78],"tags":[153],"class_list":["post-1648","post","type-post","status-publish","format-standard","hentry","category-magento","tag-redis"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1648"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1648\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}