{"id":20503,"date":"2020-03-25T10:57:18","date_gmt":"2020-03-25T01:57:18","guid":{"rendered":"https:\/\/labs.gree.jp\/blog\/?p=20503"},"modified":"2020-03-25T10:57:18","modified_gmt":"2020-03-25T01:57:18","slug":"post20503","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2020\/03\/20503\/","title":{"rendered":"\u30ea\u30fc\u30c9\u30ec\u30d7\u30ea\u30ab\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306eRedis\u30e9\u30a4\u30d6\u30e9\u30ea"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001WFS\u3067\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u3092\u62c5\u5f53\u3057\u3066\u3044\u308b\u85e4\u7530\u3067\u3059\u3002<br \/>\n\u5148\u65e5\u3001Redis\u3092\u6271\u3046\u305f\u3081\u306e\u5c0f\u3055\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u516c\u958b\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u7d39\u4ecb\u3067\u304d\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>Master-Slave-Redis<br \/>\n<a href=\"https:\/\/github.com\/gree\/master-slave-redis\">https:\/\/github.com\/gree\/master-slave-redis<\/a><\/p>\n<h1>\u3053\u308c\u306f\u4f55\u304b<\/h1>\n<p>\u3053\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u3001Redis\u304c\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u69cb\u6210\u3092\u53d6\u3063\u3066\u3044\u308b\u3068\u304d\u306b\u3001\u30de\u30b9\u30bf\u5074\u3078\u306e\u30af\u30a8\u30ea\u3068\u30ea\u30fc\u30c9\u30ec\u30d7\u30ea\u30ab\u5074\u3078\u306e\u30af\u30a8\u30ea\u3092\u51fa\u3057\u5206\u3051\u3089\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002<\/p>\n<p>\u3082\u3068\u3082\u3068\u3001\u793e\u5185\u306b\u306f\u540c\u69d8\u306e\u6a5f\u80fd\u3092\u6301\u3064\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u5b58\u5728\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001<br \/>\nCascade(https:\/\/github.com\/gree\/cascade)\u306b\u5f71\u97ff\u3055\u308c\u3066\u3044\u308b\u8a2d\u8a08\u3067\u91cd\u539a\u3060\u3063\u305f\u308a\u3001\u30d0\u30b0\u304c\u3042\u3063\u305f\u308a\u3057\u3066\u3044\u305f\u306e\u3068\u3001<br \/>\nPSR-0\/PSR-4\u304c\u7121\u3044\u6642\u4ee3\u306b\u4f5c\u3089\u308c\u3066\u3044\u305f\u308a\u3068\u3044\u3046\u306e\u304c\u3042\u308a\u3001<br \/>\n\u30b9\u30af\u30e9\u30c3\u30c1\u304b\u3089\u66f8\u304d\u76f4\u3059\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h1>\u76ee\u6307\u3057\u305f\u3053\u3068<\/h1>\n<ul>\n<li>\u6a5f\u80fd\u3092\u5c11\u306a\u304f\n<ul>\n<li>Connection Pooling\u306e\u6a5f\u80fd\u306f\u81ea\u5206\u3067\u6301\u305f\u305a\u306b\u3001Redis\u306epconnect\u306b\u4efb\u305b\u308b<\/li>\n<li>\u30e9\u30c3\u30d1\u30fc\u3067\u306f\u306a\u304f\u3001phpredis\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u76f4\u63a5\u8fd4\u3059<\/li>\n<\/ul>\n<\/li>\n<li>\u30af\u30e9\u30a6\u30c9\u306e\u30de\u30cd\u30fc\u30b8\u30c9\u306a\u30b5\u30fc\u30d3\u30b9\u306b\u5bfe\u5fdc\u3059\u308b\n<ul>\n<li>\u8907\u6570\u306e\u30ea\u30fc\u30c9\u30ec\u30d7\u30ea\u30ab\u306b\u5bfe\u3057\u3066\u3001\uff11\u3064\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u901a\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u6a5f\u80fd\u304c\u3001<br \/>\nDNS\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u5b9f\u73fe\u3055\u308c\u3066\u3044\u308b\u3068\u304d\u3001\u304d\u3061\u3093\u3068\u30af\u30a8\u30ea\u3092\u5206\u6563\u3055\u305b\u3089\u308c\u308b\u3088\u3046\u306b\u3059\u308b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>DNS\u306e\u8a71<\/h2>\n<p>DNS\u306e\u8a71\u304c\u6025\u306b\u51fa\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3053\u308c\u306fphpredis\u306epconnect\u306e\u5b9f\u88c5\u3078\u306e\u5bfe\u5fdc\u3067\u3059\u3002<\/p>\n<p>pconnect\u304c\u547c\u3073\u51fa\u3055\u308c\u305f\u3068\u304d\u3001\u30d7\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u3079\u304d\u304b\u3069\u3046\u304b\u306f\u3001<br \/>\n\u30db\u30b9\u30c8\u540d\u3068\u30dd\u30fc\u30c8\u756a\u53f7\u306e\u30bb\u30c3\u30c8\u304b\u3089\u751f\u6210\u3057\u305f<code>persistent_id<\/code>\u3068\u3044\u3046\u3082\u306e\u3092\u4f7f\u3063\u3066\u8b58\u5225\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/phpredis\/phpredis\/blob\/17ddbe76a2918f3d47176e74b14ab28a68a51b54\/library.c#L64\">https:\/\/github.com\/phpredis\/phpredis\/blob\/17ddbe76a2918f3d47176e74b14ab28a68a51b54\/library.c#L64<\/a><\/p>\n<p>\u3088\u3063\u3066\u3001\u30db\u30b9\u30c8\u540d\u304c\u8907\u6570\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u542b\u3080\u5834\u5408(\u30e9\u30a6\u30f3\u30c9\u30ed\u30d3\u30f3\u306b\u305b\u3088\u3001\u90fd\u5ea6\u90fd\u5ea6\u5225\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u306b\u306a\u308b\u306b\u305b\u3088)\u3001\u8907\u6570\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u4f7f\u3044\u5206\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<br \/>\n\u672c\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u306f\u3001\u6bce\u56de\u30db\u30b9\u30c8\u540d\u304b\u3089IP\u30a2\u30c9\u30ec\u30b9\u3092\u5f15\u3044\u3066\u3001pconnect\u306b\u306fIP\u30a2\u30c9\u30ec\u30b9\u3092\u6e21\u3059\u3053\u3068\u3067\u5206\u6563\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h1>\u4f7f\u3044\u65b9<\/h1>\n<p>\u305d\u308c\u3067\u306f\u3001\u524d\u7f6e\u304d\u306f\u3053\u306e\u304f\u3089\u3044\u306b\u3057\u3066\u304a\u3044\u3066\u3001\u4f7f\u3044\u65b9\u3092\u8aac\u660e\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:php decode:true\">$manager = new RedisManager([\n  \"master\" =&gt; [\n    \"host\" =&gt; \"master-host\",\n  ],\n  \"slave\" =&gt; [\n    [\n      \"host\" =&gt; \"slave-host\",\n    ]\n  ]\n]);\n\n$manager-&gt;getMaster()-&gt;set(\"key\", 1); \/\/ master-host\n$manager-&gt;getSlave()-&gt;get(\"key\"); \/\/ slave-host<\/pre>\n<p><code>getMaster()<\/code>\u306f\u3001<code>master-host<\/code>\u5411\u3051\u306ephpredis\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3001<code>getSlave()<\/code>\u306f\u3001<code>slave-host<\/code>\u5411\u3051\u306ephpredis\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092<br \/>\n\u305d\u308c\u305e\u308c\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u969b\u3001<code>slave-host<\/code>\u304c\u30e9\u30a6\u30f3\u30c9\u30ed\u30d3\u30f3\u3067\u8907\u6570\u306eIP\u30a2\u30c9\u30ec\u30b9\u3068\u7d10\u4ed8\u3051\u3089\u308c\u3066\u3044\u308b\u5834\u5408\u3001getSlave()\u306f\u30a2\u30af\u30bb\u30b9\u306e\u5ea6\u3001\u7570\u306a\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u8fd4\u3057\u3066\u304d\u307e\u3059\u3002<br \/>\n(\u5b9f\u88c5\u4e0a\u3001\u30de\u30b9\u30bf\u5074\u3082\u540c\u3058\u4e8b\u304c\u8d77\u3053\u308a\u307e\u3059\u304c\u3001\u305d\u3046\u3044\u3046\u3053\u3068\u306f\u7121\u3044\u3068\u5224\u65ad\u3057\u3066\u3001\u3068\u304f\u306b\u5bfe\u5fdc\u306f\u3057\u3066\u3044\u307e\u305b\u3093)<\/p>\n<p>\u305d\u306e\u4ed6\u3001\u8907\u6570\u306e\u30ec\u30d7\u30ea\u30ab\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308b\u5834\u5408\u3001\u30ec\u30d7\u30ea\u30ab\u304c\u7121\u3044\u5834\u5408\u3001\u30dd\u30fc\u30c8\u304c\u9055\u3046\u5834\u5408\u306a\u3069\u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u3001README\u306b\u307e\u3068\u3081\u3066\u3042\u308a\u307e\u3059\u306e\u3067\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u5c0f\u3055\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u306e\u3067\u3059\u304c\u3001\u6848\u5916\u30d5\u30a3\u30c3\u30c8\u3059\u308b\u3082\u306e\u304c\u7121\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u3053\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5b9f\u88c5\u3057\u3001\u516c\u958b\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n\u3082\u3057\u3001\u307f\u306a\u3055\u3093\u306e\u304a\u624b\u4f1d\u3044\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001WFS\u3067\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u3092\u62c5\u5f53\u3057\u3066\u3044\u308b\u85e4\u7530\u3067\u3059\u3002 \u5148\u65e5\u3001Redis\u3092\u6271\u3046\u305f\u3081\u306e\u5c0f\u3055\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u516c\u958b\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u7d39\u4ecb\u3067\u304d\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002 Master-Slave-Redis https:\/\/github.co [&hellip;]<\/p>\n","protected":false},"author":118,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[8,201],"class_list":["post-20503","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info","tag-php","tag-redis"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/20503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/118"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=20503"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/20503\/revisions"}],"predecessor-version":[{"id":20513,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/20503\/revisions\/20513"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=20503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=20503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=20503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}