{"id":34263,"date":"2022-11-12T02:50:04","date_gmt":"2024-03-07T06:56:56","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/"},"modified":"2024-04-29T00:14:09","modified_gmt":"2024-04-28T16:14:09","slug":"%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/","title":{"rendered":"\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879"},"content":{"rendered":"<p>\u8fd9\u662f\u5173\u4e8eRedis\u7684\u968f\u7b14\u3002\u6700\u8fd1\u6211\u5728\u63a5\u89e6\u5b83\uff0c\u5982\u679c\u6709\u4efb\u4f55\u9519\u8bef\uff0c\u8bf7\u544a\u8bc9\u6211\u3002<\/p>\n<h2>\u5185\u5bb9\u592a\u957f\uff0c\u4e0d\u8fc7\u53ea\u8981\u4e00\u79cd\u9009\u9879<\/h2>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u4f7f\u7528 AWS Elasticache \u6765\u6784\u5efa Redis \u96c6\u7fa4<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>PHP \u4e2d\u6709\u4e24\u4e2a\u8457\u540d\u7684 Redis \u5ba2\u6237\u7aef\u5b9e\u73b0<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u96c6\u7fa4\u6709\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u96c6\u7fa4\u548c\u6570\u636e\u5e93\u7f16\u53f7\u6709\u9650\u5236<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u5728\u96c6\u7fa4\u4e2d\u65e0\u6cd5\u6267\u884c SCAN \u64cd\u4f5c\uff0c\u611f\u5230\u56f0\u6270<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\u4f7f\u7528 Predis \u65f6\u9047\u5230 MOVED 1234 123.456.789:1111 Predis\\Response\\ServerException\uff0c\u611f\u5230\u56f0\u6270<\/ol>\n<h2>\u4e9a\u9a6c\u900a\u4e91\u8ba1\u7b97\uff08AWS\uff09\u5f39\u6027\u7f13\u5b58<\/h2>\n<p>\u5728AWS Elasticache\u4e0a\u521b\u5efaRedis\u5b9e\u4f8b\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9\u542f\u7528\u96c6\u7fa4\u9009\u9879\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d1c4c37434c4406c10603\/5-0.png\" alt=\"ElastiCache_Management_Console.png\" \/><\/div>\n<p>\u5982\u679c\u4e0d\u542f\u7528\u96c6\u7fa4\uff0c\u5219\u4e3b\u8981\u7aef\u70b9\u548c\u9886\u5bfc\u8005\u7aef\u70b9\u5c06\u88ab\u6fc0\u6d3b\u3002<\/p>\n<p>\u5982\u679c\u542f\u7528\u4e86\u96c6\u7fa4\uff0c\u5219\u4f1a\u542f\u7528\u201c\u8bbe\u7f6e\u7ec8\u8282\u70b9\u201d\u3002<\/p>\n<p>\u4ece\u5916\u89c2\u4e0a\u770b\uff0c\u4e3b\u8981\u7684\u7ec8\u70b9\u662f\u6570\u636e\u5e93\u91cc\u7684\u4e3b\u8282\u70b9\uff0c\u800c\u8bfb\u53d6\u7ec8\u70b9\u7c7b\u4f3c\u4e8e\u4ece\u8282\u70b9\u3002\u5728\u5199\u5165\u548c\u8bfb\u53d6\u64cd\u4f5c\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684\u7ec8\u70b9\u3002<\/p>\n<p>\u5728\u8fd9\u65b9\u9762\uff0c\u8bbe\u5b9a\u7ec8\u7aef\u662f\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\u7684\uff0c\u56e0\u4e3a\u670d\u52a1\u5668\u7aef\u5df2\u7ecf\u8fdb\u884c\u4e86\u96c6\u7fa4\u5316\u8bbe\u7f6e\uff0c\u6240\u4ee5\u5ba2\u6237\u7aef\u65e0\u9700\u7279\u522b\u5173\u6ce8\u3002<\/p>\n<h2>PHP\u6709\u4e24\u4e2aRedis\u5ba2\u6237\u7aef\u7684\u5b9e\u73b0\u3002<\/h2>\n<p>\u5728\u5904\u7406Redis\u65f6\uff0c\u4f7f\u7528PHP\u7684\u60c5\u51b5\u4e0b\uff0c\u4e00\u822c\u5e38\u89c1\u7684\u9009\u62e9\u662f\u4f7f\u7528phpredis\u6216Predis\u4e2d\u7684\u4e00\u79cd\u3002<\/p>\n<p>\u7531\u4e8ephpredis\u662f\u4e00\u4e2a\u7528C\u5b9e\u73b0\u7684PHP\u6269\u5c55\uff0c\u56e0\u6b64\u53ef\u4ee5\u671f\u671b\u5b83\u5177\u6709\u8f83\u5feb\u7684\u901f\u5ea6\u3002<\/p>\n<p>\u5728\u4e00\u65b9\u9762\uff0cPredis\u662f\u4e00\u4e2aPHP\u7684\u5b9e\u73b0\uff0c\u6240\u4ee5\u901f\u5ea6\u53ef\u80fd\u4e0d\u5982\u672c\u5730\u4ee3\u7801\uff0c\u4f46\u5b83\u4e0d\u9700\u8981\u5b89\u88c5\u6269\u5c55\uff0c\u56e0\u6b64\u66f4\u52a0\u4fbf\u643a\u3002<\/p>\n<p>Laravel \u7684 Redis \u95e8\u9762\u4f3c\u4e4e\u9ed8\u8ba4\u4f7f\u7528 Predis \u5b9e\u73b0\u3002\u4f46\u662f\uff0c\u6839\u636e\u914d\u7f6e\u53ef\u4ee5\u66f4\u6539\u4e3a phpredis \u5b9e\u73b0\u3002<\/p>\n<h2>\u96c6\u7fa4\u7684\u6ce8\u610f\u4e8b\u9879<\/h2>\n<p>\u6211\u5728\u805a\u7c7b\u4e2d\u9047\u5230\u4e86\u56f0\u96be\u3002<\/p>\n<p>\u5982\u679c\u8981\u7ec4\u6210\u96c6\u7fa4\uff0c\u4e0e\u666e\u901a\u7684\u72ec\u7acb\u5b9e\u4f8b\uff08Standalone\uff09\u76f8\u6bd4\uff0c\u53ef\u80fd\u5b58\u5728\u4e00\u4e9b\u4e0d\u540c\u4e4b\u5904\u3002<\/p>\n<p>\u987a\u4fbf\u8bf4\u4e00\u4e0b\uff0c\u8fd9\u4e9b\u662f\u6211\u5728\u4f7f\u7528Predis\u65f6\u9047\u5230\u7684\u95ee\u9898\u3002<\/p>\n<h3>\u6570\u636e\u5e93\u7f16\u53f7<\/h3>\n<p>1 \u3064\u76ee\u306f \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u5909\u66f4\u3067\u304d\u306a\u3044 \u3053\u3068\uff0e<\/p>\n<p>Redis \u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u756a\u53f7\u3068\u3044\u3046\u3082\u306e\u3092\u6301\u3063\u3066\u3044\u3066\uff0c0\u301c15 \u306e 16 \u500b\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u5207\u308a\u66ff\u3048\u3089\u308c\u308b\uff0e<\/p>\n<p>MySQL \u3067\u3044\u3046\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u3082\u3044\u3048\u305d\u3046\u3060\u304c\uff0c\u30c6\u30fc\u30d6\u30eb\u306e\u307b\u3046\u304c\u5358\u4f4d\u3068\u3057\u3066\u306f\u8fd1\u3044\u304b\u3082\u3057\u308c\u306a\u3044\uff0e<\/p>\n<p>\u3067\uff0c\u30af\u30e9\u30b9\u30bf\u3092\u7d44\u3080\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u756a\u53f7\u3092\u5909\u66f4\u3059\u308b\u3053\u3068 (SELECT) \u304c\u3067\u304d\u306a\u3044\uff0eSELECT \u3059\u308b\u3068\u30a8\u30e9\u30fc (Predis \u3060\u3068\u4f8b\u5916) \u304c\u51fa\u3066\u3057\u307e\u3044\uff0c\u30af\u30e9\u30b9\u30bf\u30e2\u30fc\u30c9\u3060\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u6307\u5b9a\u304c\u3067\u304d\u306a\u3044\u3068\u8a00\u308f\u308c\u3066\u3057\u307e\u3046\uff0e<\/p>\n<blockquote><p>\u672a\u6355\u83b7\u7684Predis\\Connection\\ConnectionException: SELECT\u64cd\u4f5c\u5931\u8d25: ERR SELECT\u5728\u96c6\u7fa4\u6a21\u5f0f\u4e0b\u4e0d\u5141\u8bb8\u4f7f\u7528<\/p><\/blockquote>\n<p>\u56e0\u6b64\uff0cDB\u7f16\u53f7\u5c06\u88ab\u56fa\u5b9a\u4e3a0\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<br \/>\n\u53c2\u8003\uff1a<\/p>\n<blockquote><p>Redis \u96c6\u7fa4\u4e0d\u652f\u6301\u50cf\u72ec\u7acb\u7248Redis\u90a3\u6837\u7684\u591a\u4e2a\u6570\u636e\u5e93\u3002 \u53ea\u6709\u4e00\u4e2a\u6570\u636e\u5e930\uff0c\u4e0d\u5141\u8bb8\u4f7f\u7528SELECT\u547d\u4ee4\u3002<\/p><\/blockquote>\n<p>Redis\u96c6\u7fa4\u89c4\u8303\u2014\u2014https:\/\/redis.io\/topics\/cluster-spec#implemented-subset<\/p>\n<h3>\u626b\u63cf<\/h3>\n<p>\u8fd9\u662f\u4e00\u4e2a\u53ef\u7591\u7684\u95ee\u9898\uff0c\u5373\u4f7f\u7528\u67d0\u4e2a\u6761\u4ef6\u6765\u7f29\u5c0f\u8303\u56f4\u5e76\u83b7\u53d6\u952e\u503c\u7684 SCAN \u529f\u80fd\u65e0\u6cd5\u4f7f\u7528\u3002<\/p>\n<blockquote><p>\u4e0d\u652f\u6301\u9884\u8bbe\u5f02\u5e38\uff1a\u65e0\u6cd5\u5728redis-cluster\u4e2d\u4f7f\u7528\u201cSCAN\u201d<\/p><\/blockquote>\n<p>\u4e3a\u4ec0\u4e48\u4f1a\u6709\u7591\u95ee\uff0c\u56e0\u4e3a\u5728GUI\u5ba2\u6237\u7aef\u4e2d\uff0c\u901a\u5e38\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528SCAN\u529f\u80fd\uff0c\u65e0\u6cd5\u4f7f\u7528SCAN\u529f\u80fd\u5b9e\u5728\u662f\u4e0d\u65b9\u4fbf\u4e14\u96be\u4ee5\u63a5\u53d7\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6709\u5f88\u5927\u53ef\u80fd\u6211\u7684\u5b9e\u73b0\u6709\u95ee\u9898\u3002\u770b\u6765\u8fd8\u9700\u8981\u518d\u6df1\u5165\u8c03\u67e5\u4e00\u4e0b\u3002<\/p>\n<blockquote><p>\u4f7f\u7528`scan`\u547d\u4ee4\u65f6\uff0c\u5b83\u4ec5\u9002\u7528\u4e8e\u5355\u4e2aRedis\u8282\u70b9\u3002\u5982\u679c\u60f3\u5728\u96c6\u7fa4\u4e2d\u4f7f\u7528\u8be5\u547d\u4ee4\uff0c\u9996\u5148\u83b7\u53d6\u96c6\u7fa4\u4e2d\u7684\u8282\u70b9\u5217\u8868\uff0c\u7136\u540e\u5bf9\u6bcf\u4e2a\u8282\u70b9\u8fd0\u884c`scan`\u547d\u4ee4\u3002<\/p><\/blockquote>\n<p>\u5728\u8fd9\u4e2aStackOverflow\u7684\u5e16\u5b50\u4e2d\uff0cSCAN\u662f\u9488\u5bf9\u4e00\u4e2a\u8282\u70b9\u7684\u64cd\u4f5c\uff0c\u56e0\u6b64\u9700\u8981\u626b\u63cf\u6574\u4e2a\u96c6\u7fa4\u5185\u7684\u6240\u6709\u8282\u70b9\u3002<\/p>\n<p>\u5982\u679c\u5728\u670d\u52a1\u5668\u96c6\u7fa4\u4e2d\u6ca1\u6709\u4eba\u6765\u7167\u987e\uff0c\u90a3\u4e48\u662f\u5426\u9700\u8981\u83b7\u53d6\u8282\u70b9\u5217\u8868\u5462\u2026\u2026\u9700\u8981\u8fdb\u884c\u8c03\u67e5\u3002<\/p>\n<p>\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0cPredis \u7684 Predis\\ClientInterface \u63a5\u53e3\u6709\u4e00\u4e2a scan \u65b9\u6cd5\uff0c\u53ef\u4ee5\u7528\u8be5\u65b9\u6cd5\u53d1\u51fa SCAN \u547d\u4ee4\u3002\u4f46\u662f\uff0c\u9700\u8981\u7ba1\u7406\u6e38\u6807\u5e76\u5faa\u73af\u904d\u5386\uff0c\u6240\u4ee5\u5728\u83b7\u53d6\u4e00\u5b9a\u91cf\u7684\u6570\u636e\u65f6\u4f7f\u7528\u8fed\u4ee3\u5668\u4f1a\u5f88\u65b9\u4fbf\uff08\u4f8b\u5982Predis\\Collection\\Iterator\\KeySpace\uff09\u3002<\/p>\n<p>\u2192 \u4f7f\u7528\u793a\u4f8b: https:\/\/github.com\/nrk\/predis\/blob\/v1.1.1\/examples\/redis_collections_iterators.php#L43-L47<\/p>\n<h3>\u5f53\u51fa\u73b0MOVED &lt;\u7aef\u53e3\u53f7&gt; &lt;IP\u5730\u5740&gt;:&lt;\u7aef\u53e3&gt; \u7684\u5f02\u5e38\u65f6<\/h3>\n<p>\u5728\u64cd\u4f5c\u65f6\u6307\u5b9a\u4e86\u96c6\u7fa4\u7684\u914d\u7f6e\u7ec8\u7aef\u70b9\uff0c\u5076\u5c14\u4f1a\u51fa\u73b0 Predis\\Response\\ServerException \u7684\u5f02\u5e38\uff0c\u4f8b\u5982 MOVED 1234 123.456.789:1111\u3002 &#8220;\u5076\u5c14&#8221; \u6307\u7684\u662f\u6bcf3\u6b21\u4e2d\u67092\u6b21\u4f1a\u51fa\u73b0\u9519\u8bef\uff0c\u800c1\u6b21\u6210\u529f\u662f\u4e00\u79cd\u5927\u81f4\u7684\u9891\u7387\u3002<\/p>\n<p>\u603b\u7684\u6765\u8bf4\uff0c\u8fd9\u662f\u56e0\u4e3a\u6211\u5728 Predis \u7684\u96c6\u7fa4\u6a21\u5f0f\u4e0b\u9519\u8bef\u5730\u6307\u5b9a\u4e86\u8fde\u63a5\u5730\u5740\u3002<\/p>\n<p>\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5f53\u521b\u5efa Predis\\Client \u5b9e\u4f8b\u65f6\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u4f7f\u7528\uff1a<\/p>\n<pre class=\"post-pre\"><code><span class=\"cp\">&lt;?php<\/span> \r\n\r\n<span class=\"kn\">use<\/span> <span class=\"nc\">Predis\\Client<\/span><span class=\"p\">;<\/span>\r\n\r\n<span class=\"k\">function<\/span> <span class=\"n\">provideClient<\/span><span class=\"p\">():<\/span> <span class=\"kt\">Client<\/span> \r\n<span class=\"p\">{<\/span>\r\n    <span class=\"nv\">$parameters<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span>\r\n        <span class=\"s1\">'host'<\/span>     <span class=\"o\">=&gt;<\/span> <span class=\"s1\">'&lt;\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8&gt;'<\/span><span class=\"p\">,<\/span>\r\n        <span class=\"s1\">'port'<\/span>     <span class=\"o\">=&gt;<\/span> <span class=\"s1\">'&lt;\u30dd\u30fc\u30c8\u756a\u53f7&gt;'<\/span><span class=\"p\">,<\/span>\r\n        <span class=\"s1\">'database'<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"mi\">0<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"p\">];<\/span>\r\n\r\n    <span class=\"k\">return<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">Client<\/span><span class=\"p\">(<\/span><span class=\"nv\">$parameters<\/span><span class=\"p\">);<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5728\u72ec\u7acb\u6a21\u5f0f\u4e0b\u6307\u5b9a\u4e00\u4e2a\u8282\u70b9\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\uff0c\u4f46\u662f\u5982\u679c\u5728\u96c6\u7fa4\u6a21\u5f0f\u4e0b\u8fde\u63a5\uff0c\u5fc5\u987b\u5728\u6784\u9020\u51fd\u6570\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e2d\u6307\u5b9a\u9009\u9879\u5173\u8054\u6570\u7ec4\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"cp\">&lt;?php<\/span> \r\n\r\n<span class=\"kn\">use<\/span> <span class=\"nc\">Predis\\Client<\/span><span class=\"p\">;<\/span>\r\n\r\n<span class=\"k\">function<\/span> <span class=\"n\">provideClient<\/span><span class=\"p\">():<\/span> <span class=\"kt\">Client<\/span> \r\n<span class=\"p\">{<\/span>\r\n    <span class=\"nv\">$parameters<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span>\r\n        <span class=\"s1\">'host'<\/span>     <span class=\"o\">=&gt;<\/span> <span class=\"s1\">'&lt;\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8&gt;'<\/span><span class=\"p\">,<\/span>\r\n        <span class=\"s1\">'port'<\/span>     <span class=\"o\">=&gt;<\/span> <span class=\"s1\">'&lt;\u30dd\u30fc\u30c8\u756a\u53f7&gt;'<\/span><span class=\"p\">,<\/span>\r\n        <span class=\"s1\">'database'<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"mi\">0<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"p\">];<\/span>\r\n    <span class=\"nv\">$options<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span>\r\n        <span class=\"s1\">'cluster'<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"s1\">'redis'<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"p\">];<\/span>\r\n\r\n    <span class=\"k\">return<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">Client<\/span><span class=\"p\">(<\/span><span class=\"nv\">$parameters<\/span><span class=\"p\">,<\/span> <span class=\"nv\">$options<\/span><span class=\"p\">);<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<p>\u6211\u539f\u4ee5\u4e3a\u53ef\u4ee5\u7528\u8fd9\u4e2a\u6765\u6307\u5b9a\u670d\u52a1\u5668\u7aef\u7684\u96c6\u7fa4\uff0c\u4f46\u4e8b\u5b9e\u8bc1\u660e\u8fd9\u662f\u4e0d\u884c\u7684\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u5728\u96c6\u7fa4\u7684\u60c5\u51b5\u4e0b\uff0c\u53c2\u6570$parameters\u9700\u8981\u6307\u5b9a\u4e00\u4e2a\u5305\u542b\u591a\u4e2a\u8fde\u63a5\u76ee\u6807\u7684\u6570\u7ec4\u3002\u65e0\u8bba\u662fAWS Elasticache\u7684Redis\u96c6\u7fa4\u8fd8\u662f\u670d\u52a1\u5668\u7aef\u7684\u4e00\u4e2a\u6258\u7ba1\u7684\u7aef\u70b9\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"cp\">&lt;?php<\/span> \r\n\r\n<span class=\"kn\">use<\/span> <span class=\"nc\">Predis\\Client<\/span><span class=\"p\">;<\/span>\r\n\r\n<span class=\"k\">function<\/span> <span class=\"n\">provideClient<\/span><span class=\"p\">():<\/span> <span class=\"kt\">Client<\/span> \r\n<span class=\"p\">{<\/span>\r\n    <span class=\"nv\">$parameters<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span>\r\n        <span class=\"p\">[<\/span>\r\n            <span class=\"s1\">'host'<\/span>     <span class=\"o\">=&gt;<\/span> <span class=\"s1\">'&lt;\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8&gt;'<\/span><span class=\"p\">,<\/span>\r\n            <span class=\"s1\">'port'<\/span>     <span class=\"o\">=&gt;<\/span> <span class=\"s1\">'&lt;\u30dd\u30fc\u30c8\u756a\u53f7&gt;'<\/span><span class=\"p\">,<\/span>\r\n            <span class=\"s1\">'database'<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"mi\">0<\/span><span class=\"p\">,<\/span>\r\n        <span class=\"p\">]<\/span>\r\n    <span class=\"p\">];<\/span>\r\n    <span class=\"nv\">$options<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span>\r\n        <span class=\"s1\">'cluster'<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"s1\">'redis'<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"p\">];<\/span>\r\n\r\n    <span class=\"k\">return<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">Client<\/span><span class=\"p\">(<\/span><span class=\"nv\">$parameters<\/span><span class=\"p\">,<\/span> <span class=\"nv\">$options<\/span><span class=\"p\">);<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<p>\u3053\u3046\u3059\u308b\u3053\u3068\u3067\uff0cMOVED &#8230; \u3082\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067\u6b63\u3057\u304f\u51e6\u7406\u3055\u308c\u3066\u30a8\u30e9\u30fc\u304c\u51fa\u306a\u304f\u306a\u3063\u305f\uff0e<\/p>\n<p>\u3061\u306a\u307f\u306b\u3053\u306e\u539f\u56e0\u306b\u306f Laravel \u306e Redis \u30d5\u30a1\u30b5\u30fc\u30c9\u306e\u5b9f\u88c5\u3092 GitHub \u3067\u78ba\u8a8d\u3057\u3066\u6c17\u3065\u3044\u305f\uff0eLaravel \u3055\u307e\u3055\u307e\u3067\u3042\u308b\uff0e<\/p>\n<p>\u2192 https:\/\/github.com\/illuminate\/redis\/blob\/5.1\/Database.php#L31-L35<\/p>\n<p>\u2192 https:\/\/github.com\/illuminate\/redis\/blob\/5.1\/Database.php\u768431-35\u884c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u5173\u4e8eRedis\u7684\u968f\u7b14\u3002\u6700\u8fd1\u6211\u5728\u63a5\u89e6\u5b83\uff0c\u5982\u679c\u6709\u4efb\u4f55\u9519\u8bef\uff0c\u8bf7\u544a\u8bc9\u6211\u3002 \u5185\u5bb9\u592a\u957f\uff0c\u4e0d\u8fc7\u53ea\u8981\u4e00\u79cd\u9009\u9879 \u4f7f\u7528 AWS [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-34263","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528aws-elasticache-redis\u96c6\u7fa4\u548cpredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\" \/>\n<meta property=\"og:description\" content=\"\u8fd9\u662f\u5173\u4e8eRedis\u7684\u968f\u7b14\u3002\u6700\u8fd1\u6211\u5728\u63a5\u89e6\u5b83\uff0c\u5982\u679c\u6709\u4efb\u4f55\u9519\u8bef\uff0c\u8bf7\u544a\u8bc9\u6211\u3002 \u5185\u5bb9\u592a\u957f\uff0c\u4e0d\u8fc7\u53ea\u8981\u4e00\u79cd\u9009\u9879 \u4f7f\u7528 AWS [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528aws-elasticache-redis\u96c6\u7fa4\u548cpredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-07T06:56:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T16:14:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d1c4c37434c4406c10603\/5-0.png\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/\",\"name\":\"\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2024-03-07T06:56:56+00:00\",\"dateModified\":\"2024-04-28T16:14:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528aws-elasticache-redis\u96c6\u7fa4\u548cpredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879","og_description":"\u8fd9\u662f\u5173\u4e8eRedis\u7684\u968f\u7b14\u3002\u6700\u8fd1\u6211\u5728\u63a5\u89e6\u5b83\uff0c\u5982\u679c\u6709\u4efb\u4f55\u9519\u8bef\uff0c\u8bf7\u544a\u8bc9\u6211\u3002 \u5185\u5bb9\u592a\u957f\uff0c\u4e0d\u8fc7\u53ea\u8981\u4e00\u79cd\u9009\u9879 \u4f7f\u7528 AWS [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528aws-elasticache-redis\u96c6\u7fa4\u548cpredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-03-07T06:56:56+00:00","article_modified_time":"2024-04-28T16:14:09+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d1c4c37434c4406c10603\/5-0.png"}],"author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/","name":"\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2024-03-07T06:56:56+00:00","dateModified":"2024-04-28T16:14:09+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528AWS Elasticache Redis\u96c6\u7fa4\u548cPredis\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8aws-elasticache-redis%e9%9b%86%e7%be%a4%e5%92%8cpredis%e6%97%b6%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a1%b9%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=34263"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34263\/revisions"}],"predecessor-version":[{"id":67519,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34263\/revisions\/67519"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=34263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=34263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=34263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}