{"id":3300,"date":"2025-03-24T08:46:29","date_gmt":"2025-03-23T23:46:29","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=3300"},"modified":"2025-03-24T08:47:00","modified_gmt":"2025-03-23T23:47:00","slug":"%e3%80%90%e4%bf%9d%e5%ad%98%e7%89%88%e3%80%91php%e3%81%a7redis%e3%82%ad%e3%83%a3%e3%83%83%e3%82%b7%e3%83%a5%e3%82%92%e6%9c%80%e9%81%a9%e5%8c%96%e3%81%99%e3%82%8b7%e3%81%a4%e3%81%ae%e5%ae%9f%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=3300","title":{"rendered":"\u3010\u4fdd\u5b58\u7248\u3011PHP\u3067Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u6700\u9069\u5316\u3059\u308b7\u3064\u306e\u5b9f\u8df5\u30c6\u30af\u30cb\u30c3\u30af"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u57fa\u790e\u77e5\u8b58<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u304a\u3051\u308b\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u91cd\u8981\u6027<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-2\">\u306a\u305cRedis\u304c\u6700\u9069\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u306a\u306e\u304b<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-3\">PHP\u3067\u306eRedis\u30ad\u30e3\u30c3\u30b7\u30e5\u5b9f\u88c5\u624b\u9806<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-4\">\u5fc5\u8981\u306a\u74b0\u5883\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068PHP\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u6e96\u5099<\/a>      <\/li>      <li>        <a href=\"#i-5\">\u57fa\u672c\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u51e6\u7406\u306e\u5b9f\u88c5\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-6\">\u52b9\u7387\u7684\u306a\u30ad\u30fc\u8a2d\u8a08\u3068\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u9078\u629e<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-7\">Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-8\">\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6709\u52b9\u671f\u9650\u8a2d\u5b9a\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>      <li>        <a href=\"#i-9\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u6291\u3048\u308b\u305f\u3081\u306e\u30c7\u30fc\u30bf\u5727\u7e2e\u624b\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-10\">\u30ad\u30e3\u30c3\u30b7\u30e5\u30d2\u30c3\u30c8\u7387\u3092\u5411\u4e0a\u3055\u305b\u308b\u305f\u3081\u306e\u30d7\u30ea\u30d5\u30a7\u30c3\u30c1\u6226\u7565<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-11\">\u9ad8\u5ea6\u306aRedis\u30ad\u30e3\u30c3\u30b7\u30e5\u30d1\u30bf\u30fc\u30f3<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-12\">\u30de\u30eb\u30c1\u30ec\u30a4\u30e4\u30fc\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u306e\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-13\">\u5206\u6563\u30ad\u30e3\u30c3\u30b7\u30e5\u74b0\u5883\u3067\u306e\u6574\u5408\u6027\u78ba\u4fdd<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-14\">\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u7121\u52b9\u5316\u3068\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u306e\u6226\u7565<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-15\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3068\u6700\u9069\u5316<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-16\">Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6307\u6a19\u3068\u76e3\u8996\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-17\">\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u306e\u7279\u5b9a\u3068\u89e3\u6c7a\u30a2\u30d7\u30ed\u30fc\u30c1<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-18\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-19\">\u5927\u898f\u6a21Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-20\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3067\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u8a2d\u8a08<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-21\">\u3088\u304f\u3042\u308b\u30c8\u30e9\u30d6\u30eb\u3068\u89e3\u6c7a\u7b56<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-22\">\u30e1\u30e2\u30ea\u4e0d\u8db3\u6642\u306e\u5bfe\u51e6\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-23\">\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6574\u5408\u6027\u304c\u5d29\u308c\u305f\u5834\u5408\u306e\u56de\u5fa9\u624b\u9806<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u57fa\u790e\u77e5\u8b58<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u304a\u3051\u308b\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u91cd\u8981\u6027<\/h3>\n\n\n\n<p>Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u958b\u767a\u306b\u304a\u3044\u3066\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316\u306f\u91cd\u8981\u306a\u8ab2\u984c\u306e\u4e00\u3064\u3067\u3059\u3002\u7279\u306bPHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u7406\u7531\u304b\u3089\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u5b9f\u88c5\u304c\u4e0d\u53ef\u6b20\u3068\u306a\u3063\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ea\u30af\u30a8\u30b9\u30c8\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u306e\u7279\u6027<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP\u306f\u30ea\u30af\u30a8\u30b9\u30c8\u3054\u3068\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c<\/li>\n\n\n\n<li>\u30bb\u30c3\u30b7\u30e7\u30f3\u9593\u3067\u306e\u30c7\u30fc\u30bf\u4fdd\u6301\u304c\u5fc5\u8981<\/li>\n\n\n\n<li>\u8907\u6570\u30b5\u30fc\u30d0\u30fc\u9593\u3067\u306e\u30c7\u30fc\u30bf\u5171\u6709\u304c\u5fc5\u8981<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u76f4\u63a5\u7684\u306a\u5f71\u97ff<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u306e\u524a\u6e1b<\/li>\n\n\n\n<li>\u8907\u96d1\u306a\u8a08\u7b97\u7d50\u679c\u306e\u518d\u5229\u7528<\/li>\n\n\n\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30ec\u30a4\u30c6\u30f3\u30b7\u306e\u4f4e\u6e1b<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d3\u30b8\u30cd\u30b9\u3078\u306e\u5f71\u97ff<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e6\u30fc\u30b6\u30fc\u4f53\u9a13\u306e\u5411\u4e0a<\/li>\n\n\n\n<li>\u30b5\u30fc\u30d0\u30fc\u30b3\u30b9\u30c8\u306e\u524a\u6e1b<\/li>\n\n\n\n<li>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5b89\u5b9a\u6027\u5411\u4e0a<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">\u306a\u305cRedis\u304c\u6700\u9069\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u306a\u306e\u304b<\/h3>\n\n\n\n<p>PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u5c64\u3068\u3057\u3066\u3001Redis\u306f\u4ee5\u4e0b\u306e\u7406\u7531\u304b\u3089\u6700\u9069\u306a\u9078\u629e\u80a2\u3068\u306a\u3063\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u7279\u6027<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30e1\u30e2\u30ea\u51e6\u7406\u306b\u3088\u308b\u9ad8\u901f\u306a\u5fdc\u7b54<\/li>\n\n\n\n<li>\u5358\u4e00\u30b9\u30ec\u30c3\u30c9\u30e2\u30c7\u30eb\u306b\u3088\u308b\u4e88\u6e2c\u53ef\u80fd\u306a\u6027\u80fd<\/li>\n\n\n\n<li>1\u30df\u30ea\u79d2\u672a\u6e80\u306e\u5e73\u5747\u30ec\u30a4\u30c6\u30f3\u30b7<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6a5f\u80fd\u9762\u3067\u306e\u512a\u4f4d\u6027<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8907\u6570\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u3092\u30cd\u30a4\u30c6\u30a3\u30d6\u30b5\u30dd\u30fc\u30c8\n<ul class=\"wp-block-list\">\n<li>String, List, Hash, Set, Sorted Set<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u30a2\u30c8\u30df\u30c3\u30af\u306a\u64cd\u4f5c\u306e\u30b5\u30dd\u30fc\u30c8<\/li>\n\n\n\n<li>\u30d1\u30d6\u30ea\u30c3\u30b7\u30e5\/\u30b5\u30d6\u30b9\u30af\u30e9\u30a4\u30d6\u6a5f\u80fd<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u904b\u7528\u9762\u3067\u306e\u5229\u70b9<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7c21\u5358\u306a\u8a2d\u5b9a\u3068\u5c0e\u5165<\/li>\n\n\n\n<li>\u8c4a\u5bcc\u306a\u7ba1\u7406\u30c4\u30fc\u30eb<\/li>\n\n\n\n<li>\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b3\u30df\u30e5\u30cb\u30c6\u30a3<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30de\u30b9\u30bf\u30fc\/\u30b9\u30ec\u30fc\u30d6\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3<\/li>\n\n\n\n<li>\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306b\u3088\u308b\u6c34\u5e73\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0<\/li>\n\n\n\n<li>Sentinel\u306b\u3088\u308b\u81ea\u52d5\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>PHP\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u89aa\u548c\u6027<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP-Redis\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3<\/li>\n\n\n\n<li>\u4e3b\u8981\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u306e\u7d71\u5408<\/li>\n\n\n\n<li>\u8c4a\u5bcc\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u30c4\u30fc\u30eb<\/li>\n<\/ul>\n\n\n\n<p>\u5177\u4f53\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u52b9\u679c\uff1a<\/p>\n\n\n<div id=\"id-9cd44f62-dee3-4ced-8661-da13f3302a69\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/th><th>Redis\u306e\u52b9\u679c<\/th><th>\u5c0e\u5165\u306e\u5bb9\u6613\u3055<\/th><\/tr><\/thead><tbody><tr><td>\u30bb\u30c3\u30b7\u30e7\u30f3\u7ba1\u7406<\/td><td>\u5fdc\u7b54\u6642\u959350%\u524a\u6e1b<\/td><td>\u5bb9\u6613<\/td><\/tr><tr><td>API\u30ad\u30e3\u30c3\u30b7\u30e5<\/td><td>\u30ec\u30a4\u30c6\u30f3\u30b770%\u6539\u5584<\/td><td>\u4e2d\u7a0b\u5ea6<\/td><\/tr><tr><td>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30ad\u30e3\u30c3\u30b7\u30e5<\/td><td>\u30b5\u30fc\u30d0\u30fc\u8ca0\u837760%\u524a\u6e1b<\/td><td>\u3084\u3084\u8907\u96d1<\/td><\/tr><tr><td>\u30ad\u30e5\u30fc\u51e6\u7406<\/td><td>\u51e6\u7406\u5f85\u3061\u6642\u959380%\u524a\u6e1b<\/td><td>\u4e2d\u7a0b\u5ea6<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<p>\u3053\u308c\u3089\u306e\u7279\u6027\u306b\u3088\u308a\u3001Redis\u306f\u73fe\u4ee3\u306ePHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u304a\u3044\u3066\u3001\u6700\u3082\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30ad\u30e3\u30c3\u30b7\u30e5\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u306e\u4e00\u3064\u3068\u3057\u3066\u5e83\u304f\u8a8d\u77e5\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u624b\u9806\u3068\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-3\">PHP\u3067\u306eRedis\u30ad\u30e3\u30c3\u30b7\u30e5\u5b9f\u88c5\u624b\u9806<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">\u5fc5\u8981\u306a\u74b0\u5883\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068PHP\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u6e96\u5099<\/h3>\n\n\n\n<p>PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067Redis\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u74b0\u5883\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306f\u3001\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u884c\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Redis\u30b5\u30fc\u30d0\u30fc\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Ubuntu\/Debian\nsudo apt-get update\nsudo apt-get install redis-server\n\n# CentOS\/RHEL\nsudo yum install redis<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>PHP-Redis\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># PHP\u62e1\u5f35\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nsudo pecl install redis\n\n# php.ini\u306b\u8ffd\u52a0\nextension=redis.so<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Composer\u3067predis\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">composer require predis\/predis<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u57fa\u672c\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u51e6\u7406\u306e\u5b9f\u88c5\u65b9\u6cd5<\/h3>\n\n\n\n<p>RedisClient\u30af\u30e9\u30b9\u306e\u57fa\u672c\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nclass RedisClient\n{\n    private $redis;\n    private $prefix = 'app:cache:';\n\n    public function __construct()\n    {\n        \/\/ Redis\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u521d\u671f\u5316\n        $this-&gt;redis = new Redis();\n        $this-&gt;redis-&gt;connect('127.0.0.1', 6379);\n\n        \/\/ \u63a5\u7d9a\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306e\u8a2d\u5b9a\n        $this-&gt;redis-&gt;setOption(Redis::OPT_READ_TIMEOUT, 0.5);\n    }\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u8a2d\u5b9a\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param mixed $value \u4fdd\u5b58\u3059\u308b\u5024\n     * @param int $ttl \u6709\u52b9\u671f\u9650\uff08\u79d2\uff09\n     * @return bool\n     *\/\n    public function set(string $key, $value, int $ttl = 3600): bool\n    {\n        $key = $this-&gt;prefix . $key;\n        \/\/ \u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u3057\u3066\u4fdd\u5b58\n        return $this-&gt;redis-&gt;setex($key, $ttl, serialize($value));\n    }\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u53d6\u5f97\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @return mixed|null\n     *\/\n    public function get(string $key)\n    {\n        $key = $this-&gt;prefix . $key;\n        $value = $this-&gt;redis-&gt;get($key);\n        return $value ? unserialize($value) : null;\n    }\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u524a\u9664\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @return bool\n     *\/\n    public function delete(string $key): bool\n    {\n        $key = $this-&gt;prefix . $key;\n        return $this-&gt;redis-&gt;del($key) &gt; 0;\n    }\n\n    \/**\n     * \u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u30ad\u30fc\u306e\u524a\u9664\n     * @param string $pattern \u30ad\u30fc\u30d1\u30bf\u30fc\u30f3\n     * @return int \u524a\u9664\u3055\u308c\u305f\u30ad\u30fc\u306e\u6570\n     *\/\n    public function deletePattern(string $pattern): int\n    {\n        $pattern = $this-&gt;prefix . $pattern;\n        $keys = $this-&gt;redis-&gt;keys($pattern);\n        return $keys ? $this-&gt;redis-&gt;del($keys) : 0;\n    }\n}<\/pre>\n\n\n\n<p>\u4f7f\u7528\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u521d\u671f\u5316\n$cache = new RedisClient();\n\n\/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u53d6\u5f97\u3057\u305f\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\n$user = [\n    'id' =&gt; 1,\n    'name' =&gt; '\u5c71\u7530\u592a\u90ce',\n    'email' =&gt; 'yamada@example.com'\n];\n$cache-&gt;set('user:1', $user, 3600); \/\/ 1\u6642\u9593\u6709\u52b9\n\n\/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u304b\u3089\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u53d6\u5f97\n$cachedUser = $cache-&gt;get('user:1');<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u52b9\u7387\u7684\u306a\u30ad\u30fc\u8a2d\u8a08\u3068\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u9078\u629e<\/h3>\n\n\n\n<p>Redis\u3067\u306e\u30ad\u30fc\u8a2d\u8a08\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ad\u30fc\u306e\u547d\u540d\u898f\u5247<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u610f\u5473\u306e\u3042\u308b\u968e\u5c64\u69cb\u9020\u3092\u4f7f\u7528<\/li>\n\n\n\n<li>\u30b3\u30ed\u30f3\uff08:\uff09\u3067\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u533a\u5207\u308b<\/li>\n\n\n\n<li>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u56fa\u6709\u306e\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u3092\u4f7f\u7528<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u826f\u3044\u4f8b\nuser:1:profile\norder:2024:01:pending\ncache:frontend:header\n\n\/\/ \u907f\u3051\u308b\u3079\u304d\u4f8b\nuserprofile1\norder_pending_202401\ncache_header<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u9078\u629e\u57fa\u6e96<\/li>\n<\/ol>\n\n\n<div id=\"id-22ba9a00-e355-4de4-8c4d-11abf449eb28\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30c7\u30fc\u30bf\u69cb\u9020<\/th><th>\u4f7f\u7528\u30b1\u30fc\u30b9<\/th><th>\u30e1\u30ea\u30c3\u30c8<\/th><\/tr><\/thead><tbody><tr><td>String<\/td><td>\u30b7\u30f3\u30d7\u30eb\u306a\u5024\u306e\u4fdd\u5b58<\/td><td>\u6700\u5c0f\u306e\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf<\/td><\/tr><tr><td>Hash<\/td><td>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30c7\u30fc\u30bf<\/td><td>\u90e8\u5206\u7684\u306a\u66f4\u65b0\u304c\u53ef\u80fd<\/td><\/tr><tr><td>List<\/td><td>\u30ad\u30e5\u30fc\u3001\u6700\u65b0\u9805\u76ee\u30ea\u30b9\u30c8<\/td><td>FIFO\/LIFO\u64cd\u4f5c\u304c\u9ad8\u901f<\/td><\/tr><tr><td>Set<\/td><td>\u30e6\u30cb\u30fc\u30af\u306a\u5024\u306e\u96c6\u5408<\/td><td>\u91cd\u8907\u9664\u53bb\u304c\u81ea\u52d5\u7684<\/td><\/tr><tr><td>Sorted Set<\/td><td>\u30e9\u30f3\u30ad\u30f3\u30b0\u3001\u512a\u5148\u5ea6\u4ed8\u304d\u30ad\u30e5\u30fc<\/td><td>\u81ea\u52d5\u7684\u306b\u30bd\u30fc\u30c8<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u8907\u5408\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u5b9f\u88c5\u4f8b\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30e6\u30fc\u30b6\u30fc\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3092\u30cf\u30c3\u30b7\u30e5\u3068\u3057\u3066\u4fdd\u5b58\n$redis-&gt;hMSet('user:1:profile', [\n    'name' =&gt; '\u5c71\u7530\u592a\u90ce',\n    'email' =&gt; 'yamada@example.com',\n    'age' =&gt; 30\n]);\n\n\/\/ \u30e6\u30fc\u30b6\u30fc\u306e\u6700\u8fd1\u306e\u6ce8\u6587\u3092\u30ea\u30b9\u30c8\u3068\u3057\u3066\u4fdd\u5b58\n$redis-&gt;lPush('user:1:recent_orders', 'ORDER123');\n$redis-&gt;lPush('user:1:recent_orders', 'ORDER124');\n\/\/ \u6700\u592710\u4ef6\u307e\u3067\u4fdd\u6301\n$redis-&gt;lTrim('user:1:recent_orders', 0, 9);\n\n\/\/ \u30e6\u30fc\u30b6\u30fc\u306e\u6a29\u9650\u3092\u30bb\u30c3\u30c8\u3068\u3057\u3066\u4fdd\u5b58\n$redis-&gt;sAdd('user:1:permissions', 'read');\n$redis-&gt;sAdd('user:1:permissions', 'write');<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u5b9f\u88c5\u306b\u3088\u308a\u3001\u52b9\u7387\u7684\u3067\u30b9\u30b1\u30fc\u30e9\u30d6\u30eb\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u57fa\u672c\u5b9f\u88c5\u3092\u30d9\u30fc\u30b9\u306b\u3001\u3055\u3089\u306a\u308b\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-7\">Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6709\u52b9\u671f\u9650\u8a2d\u5b9a\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<p>\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6709\u52b9\u671f\u9650\uff08TTL\uff09\u8a2d\u5b9a\u306f\u3001\u30e1\u30e2\u30ea\u7ba1\u7406\u3068\u30c7\u30fc\u30bf\u306e\u9bae\u5ea6\u306e\u4e21\u9762\u3067\u91cd\u8981\u3067\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u306e\u7279\u6027\u306b\u5fdc\u3058\u305fTTL\u8a2d\u5b9a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CacheService\n{\n    private $redis;\n\n    \/\/ TTL\u5b9a\u6570\u306e\u5b9a\u7fa9\n    const TTL_VERY_SHORT = 60;        \/\/ 1\u5206\n    const TTL_SHORT = 300;            \/\/ 5\u5206\n    const TTL_MEDIUM = 3600;          \/\/ 1\u6642\u9593\n    const TTL_LONG = 86400;           \/\/ 1\u65e5\n    const TTL_VERY_LONG = 604800;     \/\/ 1\u9031\u9593\n\n    \/**\n     * \u30c7\u30fc\u30bf\u306e\u66f4\u65b0\u983b\u5ea6\u306b\u57fa\u3065\u304fTTL\u8a2d\u5b9a\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param mixed $value \u4fdd\u5b58\u3059\u308b\u5024\n     * @param string $type \u30c7\u30fc\u30bf\u30bf\u30a4\u30d7\n     *\/\n    public function setWithSmartTTL(string $key, $value, string $type): void\n    {\n        $ttl = match ($type) {\n            'config' =&gt; self::TTL_VERY_LONG,    \/\/ \u30b7\u30b9\u30c6\u30e0\u8a2d\u5b9a\n            'master_data' =&gt; self::TTL_LONG,    \/\/ \u30de\u30b9\u30bf\u30fc\u30c7\u30fc\u30bf\n            'user_profile' =&gt; self::TTL_MEDIUM, \/\/ \u30e6\u30fc\u30b6\u30fc\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\n            'page_content' =&gt; self::TTL_SHORT,  \/\/ \u30da\u30fc\u30b8\u30b3\u30f3\u30c6\u30f3\u30c4\n            'api_response' =&gt; self::TTL_VERY_SHORT, \/\/ API\u5fdc\u7b54\n            default =&gt; self::TTL_MEDIUM\n        };\n\n        $this-&gt;redis-&gt;setex($key, $ttl, serialize($value));\n    }\n\n    \/**\n     * TTL\u306e\u52d5\u7684\u8abf\u6574\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param int $accessCount \u30a2\u30af\u30bb\u30b9\u56de\u6570\n     *\/\n    public function adjustTTL(string $key, int $accessCount): void\n    {\n        $currentTTL = $this-&gt;redis-&gt;ttl($key);\n        if ($currentTTL &gt; 0) {\n            \/\/ \u30a2\u30af\u30bb\u30b9\u983b\u5ea6\u306b\u5fdc\u3058\u3066TTL\u3092\u5ef6\u9577\n            $newTTL = min($currentTTL * (1 + $accessCount \/ 100), self::TTL_VERY_LONG);\n            $this-&gt;redis-&gt;expire($key, (int)$newTTL);\n        }\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u6709\u52b9\u671f\u9650\u306e\u5206\u6563\u8a2d\u5b9a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/**\n * \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6709\u52b9\u671f\u9650\u3092\u5206\u6563\u3055\u305b\u308b\n * @param int $baseTTL \u57fa\u6e96TTL\n * @return int \u5206\u6563\u3055\u305b\u305fTTL\n *\/\nprivate function getJitteredTTL(int $baseTTL): int\n{\n    \/\/ \u00b110%\u306e\u7bc4\u56f2\u3067\u30e9\u30f3\u30c0\u30e0\u306b\u5206\u6563\n    $jitter = $baseTTL * (mt_rand(-10, 10) \/ 100);\n    return max((int)($baseTTL + $jitter), 1);\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-9\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u6291\u3048\u308b\u305f\u3081\u306e\u30c7\u30fc\u30bf\u5727\u7e2e\u624b\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u5727\u7e2e\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CompressedCache\n{\n    private $redis;\n    private $compressionThreshold = 1024; \/\/ 1KB\u4ee5\u4e0a\u3092\u5727\u7e2e\n\n    \/**\n     * \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u5727\u7e2e\u3057\u3066\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u4fdd\u5b58\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param mixed $value \u4fdd\u5b58\u3059\u308b\u5024\n     * @param int $ttl \u6709\u52b9\u671f\u9650\n     *\/\n    public function set(string $key, $value, int $ttl = 3600): void\n    {\n        $serialized = serialize($value);\n\n        if (strlen($serialized) &gt; $this-&gt;compressionThreshold) {\n            \/\/ \u5727\u7e2e\u30d5\u30e9\u30b0\u3092\u4ed8\u3051\u3066\u4fdd\u5b58\n            $compressed = gzcompress($serialized, 9);\n            $this-&gt;redis-&gt;setex($key, $ttl, 'gz:' . $compressed);\n        } else {\n            $this-&gt;redis-&gt;setex($key, $ttl, $serialized);\n        }\n    }\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u304b\u3089\u53d6\u5f97\u3057\u3066\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u5c55\u958b\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @return mixed|null\n     *\/\n    public function get(string $key)\n    {\n        $value = $this-&gt;redis-&gt;get($key);\n        if (!$value) {\n            return null;\n        }\n\n        \/\/ \u5727\u7e2e\u30c7\u30fc\u30bf\u306e\u5224\u5b9a\u3068\u5c55\u958b\n        if (str_starts_with($value, 'gz:')) {\n            $value = gzuncompress(substr($value, 3));\n        }\n\n        return unserialize($value);\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u5927\u304d\u306a\u914d\u5217\u30c7\u30fc\u30bf\u306e\u683c\u7d0d\u65b9\u6cd5\n$largeArray = array_fill(0, 10000, 'some_data');\n\n\/\/ \u60aa\u3044\u4f8b\uff1a\u914d\u5217\u5168\u4f53\u30921\u3064\u306e\u30ad\u30fc\u306b\u4fdd\u5b58\n$redis-&gt;set('large_data', serialize($largeArray));\n\n\/\/ \u826f\u3044\u4f8b\uff1a\u30c1\u30e3\u30f3\u30af\u5206\u5272\u3057\u3066\u4fdd\u5b58\n$chunks = array_chunk($largeArray, 1000);\nforeach ($chunks as $i =&gt; $chunk) {\n    $redis-&gt;setex(\"large_data:chunk:$i\", 3600, serialize($chunk));\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u30ad\u30e3\u30c3\u30b7\u30e5\u30d2\u30c3\u30c8\u7387\u3092\u5411\u4e0a\u3055\u305b\u308b\u305f\u3081\u306e\u30d7\u30ea\u30d5\u30a7\u30c3\u30c1\u6226\u7565<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d7\u30ea\u30d5\u30a7\u30c3\u30c1\u306e\u5b9f\u88c5<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CachePreFetcher\n{\n    private $redis;\n    private $prefetchThreshold = 0.2; \/\/ TTL\u306e20%\u3092\u5207\u3063\u305f\u3089\u30d7\u30ea\u30d5\u30a7\u30c3\u30c1\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u53d6\u5f97\u3068\u30d7\u30ea\u30d5\u30a7\u30c3\u30c1\u306e\u5224\u65ad\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param callable $dataFetcher \u30c7\u30fc\u30bf\u53d6\u5f97\u7528\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\n     * @return mixed\n     *\/\n    public function getWithPrefetch(string $key, callable $dataFetcher)\n    {\n        $value = $this-&gt;redis-&gt;get($key);\n        $ttl = $this-&gt;redis-&gt;ttl($key);\n\n        if ($value) {\n            $maxTTL = $this-&gt;redis-&gt;object('idletime', $key) + $ttl;\n\n            \/\/ TTL\u304c\u95be\u5024\u3092\u4e0b\u56de\u3063\u305f\u5834\u5408\u3001\u975e\u540c\u671f\u3067\u30d7\u30ea\u30d5\u30a7\u30c3\u30c1\n            if ($ttl &gt; 0 &amp;&amp; $ttl &lt; ($maxTTL * $this-&gt;prefetchThreshold)) {\n                $this-&gt;asyncPrefetch($key, $dataFetcher);\n            }\n\n            return unserialize($value);\n        }\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30df\u30b9\u6642\u306e\u540c\u671f\u7684\u306a\u30c7\u30fc\u30bf\u53d6\u5f97\n        return $this-&gt;fetchAndCache($key, $dataFetcher);\n    }\n\n    \/**\n     * \u975e\u540c\u671f\u30d7\u30ea\u30d5\u30a7\u30c3\u30c1\u306e\u5b9f\u88c5\n     *\/\n    private function asyncPrefetch(string $key, callable $dataFetcher): void\n    {\n        \/\/ Gearman\u306a\u3069\u306e\u30b8\u30e7\u30d6\u30ad\u30e5\u30fc\u3092\u4f7f\u7528\n        $gearman = new GearmanClient();\n        $gearman-&gt;addServer();\n        $gearman-&gt;doBackground('cache_refresh', json_encode([\n            'key' =&gt; $key,\n            'callback' =&gt; serialize($dataFetcher)\n        ]));\n    }\n\n    \/**\n     * \u30c7\u30fc\u30bf\u53d6\u5f97\u3068\u30ad\u30e3\u30c3\u30b7\u30e5\u4fdd\u5b58\n     *\/\n    private function fetchAndCache(string $key, callable $dataFetcher)\n    {\n        $value = $dataFetcher();\n        $this-&gt;redis-&gt;setex($key, 3600, serialize($value));\n        return $value;\n    }\n}<\/pre>\n\n\n\n<p>\u4f7f\u7528\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$prefetcher = new CachePreFetcher();\n\n\/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u306e\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u53d6\u5f97\u3092\u30e9\u30c3\u30d7\n$userData = $prefetcher-&gt;getWithPrefetch('user:1:profile', function() use ($userId) {\n    return $userRepository-&gt;find($userId);\n});<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u52b9\u7387\u6027\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3055\u3089\u306b\u9ad8\u5ea6\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u30d1\u30bf\u30fc\u30f3\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-11\">\u9ad8\u5ea6\u306aRedis\u30ad\u30e3\u30c3\u30b7\u30e5\u30d1\u30bf\u30fc\u30f3<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u30de\u30eb\u30c1\u30ec\u30a4\u30e4\u30fc\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u306e\u5b9f\u88c5<\/h3>\n\n\n\n<p>\u30de\u30eb\u30c1\u30ec\u30a4\u30e4\u30fc\u30ad\u30e3\u30c3\u30b7\u30e5\u306f\u3001\u7570\u306a\u308b\u5c64\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u4fe1\u983c\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u624b\u6cd5\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class MultiLayerCache\n{\n    private $localCache = [];\n    private $redis;\n    private $memcached;\n\n    \/**\n     * \u30de\u30eb\u30c1\u30ec\u30a4\u30e4\u30fc\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u5b9f\u88c5\n     *\/\n    public function __construct()\n    {\n        $this-&gt;redis = new Redis();\n        $this-&gt;redis-&gt;connect('127.0.0.1', 6379);\n\n        $this-&gt;memcached = new Memcached();\n        $this-&gt;memcached-&gt;addServer('127.0.0.1', 11211);\n    }\n\n    \/**\n     * \u968e\u5c64\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u53d6\u5f97\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @return mixed|null\n     *\/\n    public function get(string $key)\n    {\n        \/\/ L1: \u30ed\u30fc\u30ab\u30eb\u30e1\u30e2\u30ea\u30ad\u30e3\u30c3\u30b7\u30e5\n        if (isset($this-&gt;localCache[$key])) {\n            return $this-&gt;localCache[$key];\n        }\n\n        \/\/ L2: Redis\u30ad\u30e3\u30c3\u30b7\u30e5\n        $value = $this-&gt;redis-&gt;get($key);\n        if ($value !== false) {\n            $this-&gt;localCache[$key] = unserialize($value);\n            return $this-&gt;localCache[$key];\n        }\n\n        \/\/ L3: Memcached\u30ad\u30e3\u30c3\u30b7\u30e5\n        $value = $this-&gt;memcached-&gt;get($key);\n        if ($value !== false) {\n            \/\/ Redis\u306b\u3082\u540c\u671f\n            $this-&gt;redis-&gt;setex($key, 3600, serialize($value));\n            $this-&gt;localCache[$key] = $value;\n            return $value;\n        }\n\n        return null;\n    }\n\n    \/**\n     * \u968e\u5c64\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u8a2d\u5b9a\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param mixed $value \u5024\n     * @param int $ttl TTL\uff08\u79d2\uff09\n     *\/\n    public function set(string $key, $value, int $ttl = 3600): void\n    {\n        \/\/ \u3059\u3079\u3066\u306e\u5c64\u306b\u66f8\u304d\u8fbc\u307f\n        $this-&gt;localCache[$key] = $value;\n        $this-&gt;redis-&gt;setex($key, $ttl, serialize($value));\n        $this-&gt;memcached-&gt;set($key, $value, $ttl);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u5206\u6563\u30ad\u30e3\u30c3\u30b7\u30e5\u74b0\u5883\u3067\u306e\u6574\u5408\u6027\u78ba\u4fdd<\/h3>\n\n\n\n<p>\u5206\u6563\u74b0\u5883\u3067\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u6574\u5408\u6027\u3092\u7dad\u6301\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class DistributedCache\n{\n    private $redis;\n    private $lockTimeout = 30; \/\/ \u30ed\u30c3\u30af\u306e\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\uff08\u79d2\uff09\n\n    \/**\n     * \u5206\u6563\u30ed\u30c3\u30af\u3092\u4f7f\u7528\u3057\u305f\u30ad\u30e3\u30c3\u30b7\u30e5\u66f4\u65b0\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param callable $dataProvider \u30c7\u30fc\u30bf\u53d6\u5f97\u7528\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\n     * @return mixed\n     *\/\n    public function getWithLock(string $key, callable $dataProvider)\n    {\n        $value = $this-&gt;redis-&gt;get($key);\n        if ($value !== false) {\n            return unserialize($value);\n        }\n\n        $lockKey = \"lock:{$key}\";\n        $lockValue = uniqid();\n\n        try {\n            \/\/ \u5206\u6563\u30ed\u30c3\u30af\u306e\u53d6\u5f97\n            if ($this-&gt;acquireLock($lockKey, $lockValue)) {\n                $value = $dataProvider();\n                $this-&gt;redis-&gt;setex($key, 3600, serialize($value));\n                return $value;\n            }\n\n            \/\/ \u30ed\u30c3\u30af\u53d6\u5f97\u5f85\u3061\n            for ($i = 0; $i &lt; 3; $i++) {\n                usleep(100000); \/\/ 100ms\u5f85\u6a5f\n                $value = $this-&gt;redis-&gt;get($key);\n                if ($value !== false) {\n                    return unserialize($value);\n                }\n            }\n\n            \/\/ \u6700\u7d42\u7684\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u306a\u3044\u5834\u5408\n            throw new RuntimeException('Failed to get cached data');\n        } finally {\n            $this-&gt;releaseLock($lockKey, $lockValue);\n        }\n    }\n\n    \/**\n     * Redis\u3092\u4f7f\u7528\u3057\u305f\u5206\u6563\u30ed\u30c3\u30af\u306e\u53d6\u5f97\n     *\/\n    private function acquireLock(string $lockKey, string $lockValue): bool\n    {\n        return $this-&gt;redis-&gt;set(\n            $lockKey,\n            $lockValue,\n            ['NX', 'EX' =&gt; $this-&gt;lockTimeout]\n        );\n    }\n\n    \/**\n     * \u30ed\u30c3\u30af\u306e\u89e3\u653e\n     *\/\n    private function releaseLock(string $lockKey, string $lockValue): void\n    {\n        \/\/ \u30ed\u30c3\u30af\u6240\u6709\u8005\u306e\u78ba\u8a8d\u3068\u89e3\u653e\u3092\u4e00\u3064\u306e\u30a2\u30c8\u30df\u30c3\u30af\u306a\u64cd\u4f5c\u3067\u5b9f\u884c\n        $script = &lt;&lt;&lt;LUA\n        if redis.call('get', KEYS[1]) == ARGV[1] then\n            return redis.call('del', KEYS[1])\n        end\n        return 0\n        LUA;\n\n        $this-&gt;redis-&gt;eval($script, [$lockKey, $lockValue], 1);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u7121\u52b9\u5316\u3068\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u306e\u6226\u7565<\/h3>\n\n\n\n<p>\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u52b9\u7387\u7684\u306a\u7121\u52b9\u5316\u3068\u66f4\u65b0\u7ba1\u7406\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CacheInvalidationManager\n{\n    private $redis;\n    private $versionPrefix = 'version:';\n    private $dataPrefix = 'data:';\n\n    \/**\n     * \u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u53d6\u5f97\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @return mixed|null\n     *\/\n    public function getVersioned(string $key)\n    {\n        $version = $this-&gt;redis-&gt;get($this-&gt;versionPrefix . $key) ?: '1';\n        $value = $this-&gt;redis-&gt;get($this-&gt;dataPrefix . $key . ':' . $version);\n        return $value ? unserialize($value) : null;\n    }\n\n    \/**\n     * \u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u8a2d\u5b9a\n     * @param string $key \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param mixed $value \u5024\n     *\/\n    public function setVersioned(string $key, $value): void\n    {\n        $version = $this-&gt;redis-&gt;incr($this-&gt;versionPrefix . $key);\n        $this-&gt;redis-&gt;setex(\n            $this-&gt;dataPrefix . $key . ':' . $version,\n            3600,\n            serialize($value)\n        );\n\n        \/\/ \u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u975e\u540c\u671f\u3067\u524a\u9664\n        $this-&gt;scheduleOldVersionCleanup($key, $version);\n    }\n\n    \/**\n     * \u4f9d\u5b58\u95a2\u4fc2\u3092\u8003\u616e\u3057\u305f\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u7121\u52b9\u5316\n     * @param string $key \u30d7\u30e9\u30a4\u30de\u30ea\u30ad\u30fc\n     * @param array $dependencies \u4f9d\u5b58\u3059\u308b\u30ad\u30fc\u306e\u914d\u5217\n     *\/\n    public function invalidateWithDependencies(string $key, array $dependencies): void\n    {\n        $this-&gt;redis-&gt;multi();\n\n        \/\/ \u30d7\u30e9\u30a4\u30de\u30ea\u30ad\u30fc\u306e\u7121\u52b9\u5316\n        $this-&gt;redis-&gt;incr($this-&gt;versionPrefix . $key);\n\n        \/\/ \u4f9d\u5b58\u3059\u308b\u30ad\u30fc\u306e\u7121\u52b9\u5316\n        foreach ($dependencies as $depKey) {\n            $this-&gt;redis-&gt;incr($this-&gt;versionPrefix . $depKey);\n        }\n\n        $this-&gt;redis-&gt;exec();\n    }\n\n    \/**\n     * \u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\n     *\/\n    private function scheduleOldVersionCleanup(string $key, int $currentVersion): void\n    {\n        $pattern = $this-&gt;dataPrefix . $key . ':*';\n        $keys = $this-&gt;redis-&gt;keys($pattern);\n\n        foreach ($keys as $k) {\n            $keyVersion = (int)substr($k, strrpos($k, ':') + 1);\n            if ($keyVersion &lt; $currentVersion) {\n                $this-&gt;redis-&gt;del($k);\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u4f7f\u7528\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30de\u30eb\u30c1\u30ec\u30a4\u30e4\u30fc\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u4f7f\u7528\n$cache = new MultiLayerCache();\n$cache-&gt;set('user:profile:1', $userData);\n$profile = $cache-&gt;get('user:profile:1');\n\n\/\/ \u5206\u6563\u30ed\u30c3\u30af\u3092\u4f7f\u7528\u3057\u305f\u30ad\u30e3\u30c3\u30b7\u30e5\u66f4\u65b0\n$distributedCache = new DistributedCache();\n$data = $distributedCache-&gt;getWithLock('expensive:calculation', function() {\n    return $this-&gt;performExpensiveCalculation();\n});\n\n\/\/ \u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u4f7f\u7528\n$invalidationManager = new CacheInvalidationManager();\n$invalidationManager-&gt;setVersioned('product:1', $productData);\n$invalidationManager-&gt;invalidateWithDependencies('product:1', [\n    'category:5',\n    'brand:3'\n]);<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u9ad8\u5ea6\u306a\u30d1\u30bf\u30fc\u30f3\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u8907\u96d1\u306a\u8981\u4ef6\u306b\u3082\u5bfe\u5fdc\u3067\u304d\u308b\u5805\u7262\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u5b9f\u88c5\u3057\u305f\u969b\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3068\u6700\u9069\u5316\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-15\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3068\u6700\u9069\u5316<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6307\u6a19\u3068\u76e3\u8996\u65b9\u6cd5<\/h3>\n\n\n\n<p>Redis\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u52b9\u679c\u7684\u306b\u76e3\u8996\u30fb\u5206\u6790\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class RedisCacheMonitor\n{\n    private $redis;\n    private $metricsPrefix = 'metrics:';\n    private $sampleRate = 0.1; \/\/ \u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u30ec\u30fc\u30c8\uff0810%\uff09\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u64cd\u4f5c\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8a08\u6e2c\n     * @param string $operation \u64cd\u4f5c\u540d\n     * @param callable $callback \u8a08\u6e2c\u5bfe\u8c61\u306e\u51e6\u7406\n     * @return mixed\n     *\/\n    public function measureOperation(string $operation, callable $callback)\n    {\n        \/\/ \u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u306e\u5224\u5b9a\n        if (rand(1, 100) \/ 100 &gt; $this-&gt;sampleRate) {\n            return $callback();\n        }\n\n        $startTime = microtime(true);\n        $startMemory = memory_get_usage();\n\n        try {\n            $result = $callback();\n\n            $endTime = microtime(true);\n            $endMemory = memory_get_usage();\n\n            \/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a18\u9332\n            $this-&gt;recordMetrics($operation, [\n                'duration' =&gt; ($endTime - $startTime) * 1000, \/\/ \u30df\u30ea\u79d2\u306b\u5909\u63db\n                'memory' =&gt; $endMemory - $startMemory,\n                'timestamp' =&gt; time()\n            ]);\n\n            return $result;\n        } catch (Exception $e) {\n            \/\/ \u30a8\u30e9\u30fc\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a18\u9332\n            $this-&gt;recordError($operation, $e);\n            throw $e;\n        }\n    }\n\n    \/**\n     * \u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a18\u9332\n     * @param string $operation \u64cd\u4f5c\u540d\n     * @param array $metrics \u30e1\u30c8\u30ea\u30af\u30b9\u60c5\u5831\n     *\/\n    private function recordMetrics(string $operation, array $metrics): void\n    {\n        $key = $this-&gt;metricsPrefix . $operation;\n\n        \/\/ \u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3092\u30b9\u30b3\u30a2\u3068\u3057\u3066\u4f7f\u7528\u3057\u305f\u30bd\u30fc\u30c8\u6e08\u307f\u30bb\u30c3\u30c8\n        $this-&gt;redis-&gt;zAdd(\n            $key . ':durations',\n            $metrics['timestamp'],\n            json_encode([\n                'duration' =&gt; $metrics['duration'],\n                'memory' =&gt; $metrics['memory']\n            ])\n        );\n\n        \/\/ \u76f4\u8fd11\u6642\u9593\u306e\u30c7\u30fc\u30bf\u306e\u307f\u4fdd\u6301\n        $this-&gt;redis-&gt;zRemRangeByScore(\n            $key . ':durations',\n            0,\n            time() - 3600\n        );\n\n        \/\/ \u96c6\u8a08\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\n        $this-&gt;updateAggregates($operation, $metrics);\n    }\n\n    \/**\n     * \u96c6\u8a08\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\n     * @param string $operation \u64cd\u4f5c\u540d\n     * @param array $metrics \u30e1\u30c8\u30ea\u30af\u30b9\u60c5\u5831\n     *\/\n    private function updateAggregates(string $operation, array $metrics): void\n    {\n        $key = $this-&gt;metricsPrefix . $operation;\n\n        \/\/ \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3067\u8907\u6570\u306e\u66f4\u65b0\u3092\u4e00\u62ec\u5b9f\u884c\n        $this-&gt;redis-&gt;multi()\n            -&gt;hIncrByFloat($key . ':stats', 'total_duration', $metrics['duration'])\n            -&gt;hIncrBy($key . ':stats', 'total_calls', 1)\n            -&gt;hSet($key . ':stats', 'last_duration', $metrics['duration'])\n            -&gt;hSet($key . ':stats', 'last_memory', $metrics['memory'])\n            -&gt;exec();\n    }\n\n    \/**\n     * \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30ec\u30dd\u30fc\u30c8\u306e\u751f\u6210\n     * @param string $operation \u64cd\u4f5c\u540d\n     * @return array\n     *\/\n    public function generateReport(string $operation): array\n    {\n        $key = $this-&gt;metricsPrefix . $operation;\n        $stats = $this-&gt;redis-&gt;hGetAll($key . ':stats');\n\n        if (empty($stats)) {\n            return ['error' =&gt; 'No metrics available'];\n        }\n\n        \/\/ \u5e73\u5747\u5024\u306e\u8a08\u7b97\n        $avgDuration = $stats['total_duration'] \/ $stats['total_calls'];\n\n        \/\/ \u76f4\u8fd1\u306e\u30c7\u30fc\u30bf\u53d6\u5f97\n        $recentMetrics = $this-&gt;redis-&gt;zRevRangeByScore(\n            $key . ':durations',\n            '+inf',\n            time() - 300, \/\/ \u76f4\u8fd15\u5206\n            ['withscores' =&gt; true]\n        );\n\n        \/\/ \u30d1\u30fc\u30bb\u30f3\u30bf\u30a4\u30eb\u306e\u8a08\u7b97\n        $durations = array_map(function($metric) {\n            return json_decode($metric, true)['duration'];\n        }, array_keys($recentMetrics));\n        sort($durations);\n\n        $count = count($durations);\n        $p95 = $count &gt; 0 ? $durations[(int)($count * 0.95)] : 0;\n        $p99 = $count &gt; 0 ? $durations[(int)($count * 0.99)] : 0;\n\n        return [\n            'average_duration' =&gt; $avgDuration,\n            'p95_duration' =&gt; $p95,\n            'p99_duration' =&gt; $p99,\n            'total_calls' =&gt; (int)$stats['total_calls'],\n            'last_duration' =&gt; (float)$stats['last_duration'],\n            'last_memory' =&gt; (int)$stats['last_memory']\n        ];\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u306e\u7279\u5b9a\u3068\u89e3\u6c7a\u30a2\u30d7\u30ed\u30fc\u30c1<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CachePerformanceAnalyzer\n{\n    private $monitor;\n    private $redis;\n    private $thresholds = [\n        'duration_warning' =&gt; 100,  \/\/ 100ms\n        'duration_critical' =&gt; 500, \/\/ 500ms\n        'memory_warning' =&gt; 5242880,  \/\/ 5MB\n        'memory_critical' =&gt; 52428800 \/\/ 50MB\n    ];\n\n    \/**\n     * \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5206\u6790\u306e\u5b9f\u884c\n     * @param string $operation \u64cd\u4f5c\u540d\n     * @return array\n     *\/\n    public function analyzePerformance(string $operation): array\n    {\n        $report = $this-&gt;monitor-&gt;generateReport($operation);\n        $issues = [];\n\n        \/\/ \u30ec\u30a4\u30c6\u30f3\u30b7\u306e\u5206\u6790\n        if ($report['p95_duration'] &gt; $this-&gt;thresholds['duration_critical']) {\n            $issues[] = [\n                'level' =&gt; 'critical',\n                'type' =&gt; 'latency',\n                'message' =&gt; '95\u30d1\u30fc\u30bb\u30f3\u30bf\u30a4\u30eb\u306e\u30ec\u30a4\u30c6\u30f3\u30b7\u304c\u8a31\u5bb9\u5024\u3092\u8d85\u904e',\n                'value' =&gt; $report['p95_duration'],\n                'threshold' =&gt; $this-&gt;thresholds['duration_critical'],\n                'recommendation' =&gt; $this-&gt;getLatencyRecommendations($report)\n            ];\n        } elseif ($report['p95_duration'] &gt; $this-&gt;thresholds['duration_warning']) {\n            $issues[] = [\n                'level' =&gt; 'warning',\n                'type' =&gt; 'latency',\n                'message' =&gt; '\u30ec\u30a4\u30c6\u30f3\u30b7\u304c\u8b66\u544a\u95be\u5024\u3092\u8d85\u904e',\n                'value' =&gt; $report['p95_duration'],\n                'threshold' =&gt; $this-&gt;thresholds['duration_warning'],\n                'recommendation' =&gt; $this-&gt;getLatencyRecommendations($report)\n            ];\n        }\n\n        \/\/ \u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u5206\u6790\n        if ($report['last_memory'] &gt; $this-&gt;thresholds['memory_critical']) {\n            $issues[] = [\n                'level' =&gt; 'critical',\n                'type' =&gt; 'memory',\n                'message' =&gt; '\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c\u5371\u967a\u6c34\u6e96',\n                'value' =&gt; $report['last_memory'],\n                'threshold' =&gt; $this-&gt;thresholds['memory_critical'],\n                'recommendation' =&gt; $this-&gt;getMemoryRecommendations()\n            ];\n        }\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30d2\u30c3\u30c8\u7387\u306e\u5206\u6790\n        $hitRate = $this-&gt;analyzeHitRate($operation);\n        if ($hitRate &lt; 0.8) { \/\/ 80%\u672a\u6e80\n            $issues[] = [\n                'level' =&gt; 'warning',\n                'type' =&gt; 'cache_hits',\n                'message' =&gt; '\u30ad\u30e3\u30c3\u30b7\u30e5\u30d2\u30c3\u30c8\u7387\u304c\u4f4e\u4e0b',\n                'value' =&gt; $hitRate,\n                'threshold' =&gt; 0.8,\n                'recommendation' =&gt; $this-&gt;getHitRateRecommendations()\n            ];\n        }\n\n        return [\n            'issues' =&gt; $issues,\n            'metrics' =&gt; $report,\n            'hit_rate' =&gt; $hitRate\n        ];\n    }\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u30d2\u30c3\u30c8\u7387\u306e\u5206\u6790\n     * @param string $operation \u64cd\u4f5c\u540d\n     * @return float\n     *\/\n    private function analyzeHitRate(string $operation): float\n    {\n        $info = $this-&gt;redis-&gt;info();\n        $keyspace = $info['keyspace'] ?? [];\n\n        $hits = $info['keyspace_hits'] ?? 0;\n        $misses = $info['keyspace_misses'] ?? 0;\n        $total = $hits + $misses;\n\n        return $total &gt; 0 ? $hits \/ $total : 0;\n    }\n\n    \/**\n     * \u30ec\u30a4\u30c6\u30f3\u30b7\u6539\u5584\u306e\u63a8\u5968\u4e8b\u9805\u53d6\u5f97\n     * @param array $report \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30ec\u30dd\u30fc\u30c8\n     * @return array\n     *\/\n    private function getLatencyRecommendations(array $report): array\n    {\n        $recommendations = [];\n\n        if ($report['p99_duration'] &gt; 1000) { \/\/ 1\u79d2\u4ee5\u4e0a\n            $recommendations[] = 'Redis\u30b5\u30fc\u30d0\u30fc\u306e\u30ea\u30bd\u30fc\u30b9\u5897\u5f37\u3092\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044';\n            $recommendations[] = '\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30ec\u30a4\u30c6\u30f3\u30b7\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044';\n        }\n\n        if ($report['average_duration'] &gt; 200) { \/\/ 200ms\u4ee5\u4e0a\n            $recommendations[] = '\u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\u306e\u8a2d\u8a08\u3092\u898b\u76f4\u3057\u3066\u304f\u3060\u3055\u3044';\n            $recommendations[] = '\u30c7\u30fc\u30bf\u69cb\u9020\u306e\u6700\u9069\u5316\u3092\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044';\n        }\n\n        return $recommendations;\n    }\n\n    \/**\n     * \u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u6539\u5584\u306e\u63a8\u5968\u4e8b\u9805\u53d6\u5f97\n     * @return array\n     *\/\n    private function getMemoryRecommendations(): array\n    {\n        return [\n            '\u30c7\u30fc\u30bf\u306e\u5727\u7e2e\u3092\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044',\n            '\u4e0d\u8981\u306a\u30ad\u30fc\u306e\u524a\u9664\u3092\u5b9f\u65bd\u3057\u3066\u304f\u3060\u3055\u3044',\n            'TTL\u306e\u898b\u76f4\u3057\u3092\u884c\u3063\u3066\u304f\u3060\u3055\u3044',\n            '\u30e1\u30e2\u30ea\u4e0a\u9650\u306e\u5f15\u304d\u4e0a\u3052\u3092\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044'\n        ];\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$monitor = new RedisCacheMonitor();\n$analyzer = new CachePerformanceAnalyzer();\n\n\/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u64cd\u4f5c\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8a08\u6e2c\n$result = $monitor-&gt;measureOperation('get_user_profile', function() use ($cache) {\n    return $cache-&gt;get('user:profile:1');\n});\n\n\/\/ \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5206\u6790\u306e\u5b9f\u884c\n$analysis = $analyzer-&gt;analyzePerformance('get_user_profile');\n\n\/\/ \u5206\u6790\u7d50\u679c\u306b\u57fa\u3065\u304f\u5bfe\u5fdc\nif (!empty($analysis['issues'])) {\n    foreach ($analysis['issues'] as $issue) {\n        if ($issue['level'] === 'critical') {\n            \/\/ \u30af\u30ea\u30c6\u30a3\u30ab\u30eb\u306a\u554f\u984c\u306e\u901a\u77e5\n            $this-&gt;notifyDevTeam($issue);\n        }\n\n        \/\/ \u63a8\u5968\u5bfe\u5fdc\u306e\u5b9f\u65bd\n        foreach ($issue['recommendation'] as $recommendation) {\n            $this-&gt;logRecommendation($recommendation);\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u306e\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3068\u5206\u6790\u30b7\u30b9\u30c6\u30e0\u306b\u3088\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u52b9\u679c\u304c\u671f\u5f85\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u554f\u984c\u306e\u65e9\u671f\u767a\u898b<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30ec\u30a4\u30c6\u30f3\u30b7\u306e\u7570\u5e38\u691c\u77e5<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u76e3\u8996<\/li>\n\n\n\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u30d2\u30c3\u30c8\u7387\u306e\u8ffd\u8de1<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u81ea\u52d5\u7684\u306a\u554f\u984c\u8a3a\u65ad<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u306e\u7279\u5b9a<\/li>\n\n\n\n<li>\u539f\u56e0\u306e\u5206\u6790<\/li>\n\n\n\n<li>\u6539\u5584\u63d0\u6848\u306e\u751f\u6210<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c7\u30fc\u30bf\u306b\u57fa\u3065\u304f\u6700\u9069\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u306e\u8abf\u6574<\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9\u914d\u5206\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u30b7\u30b9\u30c6\u30e0\u8a2d\u5b9a\u306e\u8abf\u6574<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6a5f\u80fd\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u30b7\u30b9\u30c6\u30e0\u306e\u7d99\u7d9a\u7684\u306a\u6539\u5584\u3068\u5b89\u5b9a\u904b\u7528\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-18\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">\u5927\u898f\u6a21Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565<\/h3>\n\n\n\n<p>\u5927\u898f\u6a21Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u8907\u6570\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u5c64\u3092\u52b9\u679c\u7684\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u5b9f\u8df5\u7684\u306a\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class WebAppCacheManager\n{\n    private $redis;\n    private $localCache = [];\n    private $cachePrefixes = [\n        'page' =&gt; 'page:cache:',\n        'api' =&gt; 'api:response:',\n        'user' =&gt; 'user:data:',\n        'product' =&gt; 'product:info:'\n    ];\n\n    \/**\n     * \u30da\u30fc\u30b8\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u5b9f\u88c5\n     * @param string $url \u30da\u30fc\u30b8URL\n     * @param array $params \u30ea\u30af\u30a8\u30b9\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\n     * @return array|null\n     *\/\n    public function getPageCache(string $url, array $params = []): ?array\n    {\n        $cacheKey = $this-&gt;buildPageCacheKey($url, $params);\n\n        \/\/ \u968e\u5c64\u7684\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u5b9f\u88c5\n        if (isset($this-&gt;localCache[$cacheKey])) {\n            return $this-&gt;localCache[$cacheKey];\n        }\n\n        $cachedData = $this-&gt;redis-&gt;get($cacheKey);\n        if ($cachedData) {\n            $this-&gt;localCache[$cacheKey] = unserialize($cachedData);\n            return $this-&gt;localCache[$cacheKey];\n        }\n\n        return null;\n    }\n\n    \/**\n     * API\u30ec\u30b9\u30dd\u30f3\u30b9\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u5b9f\u88c5\n     * @param string $endpoint API\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\n     * @param array $params \u30ea\u30af\u30a8\u30b9\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\n     * @param callable $dataFetcher \u30c7\u30fc\u30bf\u53d6\u5f97\u7528\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\n     * @return array\n     *\/\n    public function getCachedApiResponse(\n        string $endpoint,\n        array $params,\n        callable $dataFetcher\n    ): array {\n        $cacheKey = $this-&gt;buildApiCacheKey($endpoint, $params);\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u53d6\u5f97\u3068\u66f4\u65b0\n        $cachedResponse = $this-&gt;redis-&gt;get($cacheKey);\n        if ($cachedResponse) {\n            $data = unserialize($cachedResponse);\n            \/\/ \u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u306e\u975e\u540c\u671f\u66f4\u65b0\n            if ($this-&gt;shouldRefreshCache($data['cached_at'])) {\n                $this-&gt;scheduleBackgroundRefresh($cacheKey, $dataFetcher);\n            }\n            return $data['response'];\n        }\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30df\u30b9\u6642\u306e\u51e6\u7406\n        $response = $dataFetcher();\n        $this-&gt;redis-&gt;setex($cacheKey, 3600, serialize([\n            'response' =&gt; $response,\n            'cached_at' =&gt; time()\n        ]));\n\n        return $response;\n    }\n\n    \/**\n     * \u30e6\u30fc\u30b6\u30fc\u30bb\u30c3\u30b7\u30e7\u30f3\u95a2\u9023\u30c7\u30fc\u30bf\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\n     * @param int $userId \u30e6\u30fc\u30b6\u30fcID\n     * @return array\n     *\/\n    public function getUserSessionData(int $userId): array\n    {\n        $cacheKey = $this-&gt;cachePrefixes['user'] . $userId;\n\n        \/\/ \u30bb\u30c3\u30b7\u30e7\u30f3\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\n        $sessionData = $this-&gt;redis-&gt;hGetAll($cacheKey);\n        if (empty($sessionData)) {\n            \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u306e\u53d6\u5f97\u3068\u66f4\u65b0\n            $sessionData = $this-&gt;loadUserDataFromDb($userId);\n            $this-&gt;redis-&gt;hMSet($cacheKey, $sessionData);\n            $this-&gt;redis-&gt;expire($cacheKey, 7200); \/\/ 2\u6642\u9593\n        }\n\n        \/\/ \u30a2\u30af\u30bb\u30b9\u7d71\u8a08\u306e\u66f4\u65b0\n        $this-&gt;redis-&gt;zIncrBy(\n            'user:access:frequency',\n            1,\n            (string)$userId\n        );\n\n        return $sessionData;\n    }\n\n    \/**\n     * \u5546\u54c1\u60c5\u5831\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u7ba1\u7406\n     * @param int $productId \u5546\u54c1ID\n     * @return array\n     *\/\n    public function getProductInfo(int $productId): array\n    {\n        $cacheKey = $this-&gt;cachePrefixes['product'] . $productId;\n\n        \/\/ \u5546\u54c1\u60c5\u5831\u306e\u53d6\u5f97\n        $productData = $this-&gt;redis-&gt;get($cacheKey);\n        if ($productData) {\n            return unserialize($productData);\n        }\n\n        \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u306e\u53d6\u5f97\n        $productInfo = $this-&gt;loadProductFromDb($productId);\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u8a2d\u5b9a\uff08\u5728\u5eab\u6570\u306f\u5225\u30ad\u30fc\u3067\u7ba1\u7406\uff09\n        $this-&gt;redis-&gt;setex($cacheKey, 3600, serialize($productInfo));\n        $this-&gt;redis-&gt;set(\n            $this-&gt;cachePrefixes['product'] . \"stock:{$productId}\",\n            $productInfo['stock'],\n            ['EX' =&gt; 60] \/\/ \u5728\u5eab\u306f1\u5206\u9593\u306e\u307f\u30ad\u30e3\u30c3\u30b7\u30e5\n        );\n\n        return $productInfo;\n    }\n\n    \/**\n     * \u5728\u5eab\u6570\u306e\u66f4\u65b0\uff08\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u4f7f\u7528\uff09\n     * @param int $productId \u5546\u54c1ID\n     * @param int $quantity \u6570\u91cf\n     * @return bool\n     *\/\n    public function updateProductStock(int $productId, int $quantity): bool\n    {\n        $stockKey = $this-&gt;cachePrefixes['product'] . \"stock:{$productId}\";\n\n        \/\/ \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3067\u306e\u5728\u5eab\u66f4\u65b0\n        $this-&gt;redis-&gt;multi();\n        $this-&gt;redis-&gt;get($stockKey);\n        $this-&gt;redis-&gt;set($stockKey, $quantity, ['EX' =&gt; 60]);\n        $results = $this-&gt;redis-&gt;exec();\n\n        if ($results) {\n            \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u975e\u540c\u671f\u66f4\u65b0\n            $this-&gt;scheduleStockUpdate($productId, $quantity);\n            return true;\n        }\n\n        return false;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3067\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u8a2d\u8a08<\/h3>\n\n\n\n<p>\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u74b0\u5883\u3067\u306e\u52b9\u7387\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u7ba1\u7406\u306e\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class MicroserviceCacheManager\n{\n    private $redis;\n    private $serviceName;\n    private $eventBus;\n\n    \/**\n     * \u30b5\u30fc\u30d3\u30b9\u9593\u3067\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u6574\u5408\u6027\u7ba1\u7406\n     * @param string $resourceType \u30ea\u30bd\u30fc\u30b9\u30bf\u30a4\u30d7\n     * @param string $resourceId \u30ea\u30bd\u30fc\u30b9ID\n     * @param array $data \u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\n     *\/\n    public function updateDistributedCache(\n        string $resourceType,\n        string $resourceId,\n        array $data\n    ): void {\n        \/\/ \u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u305f\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u66f4\u65b0\n        $version = $this-&gt;redis-&gt;incr(\"version:{$resourceType}:{$resourceId}\");\n        $cacheKey = \"data:{$resourceType}:{$resourceId}:v{$version}\";\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u306e\u8a2d\u5b9a\n        $this-&gt;redis-&gt;setex($cacheKey, 3600, serialize($data));\n\n        \/\/ \u4ed6\u306e\u30b5\u30fc\u30d3\u30b9\u3078\u306e\u901a\u77e5\n        $this-&gt;eventBus-&gt;publish('cache.updated', [\n            'service' =&gt; $this-&gt;serviceName,\n            'resource_type' =&gt; $resourceType,\n            'resource_id' =&gt; $resourceId,\n            'version' =&gt; $version,\n            'timestamp' =&gt; microtime(true)\n        ]);\n    }\n\n    \/**\n     * \u30b5\u30fc\u30d3\u30b9\u9593\u3067\u306e\u30c7\u30fc\u30bf\u540c\u671f\n     * @param string $resourceType \u30ea\u30bd\u30fc\u30b9\u30bf\u30a4\u30d7\n     * @param string $resourceId \u30ea\u30bd\u30fc\u30b9ID\n     * @return array\n     *\/\n    public function getSynchronizedData(\n        string $resourceType,\n        string $resourceId\n    ): array {\n        $version = $this-&gt;redis-&gt;get(\"version:{$resourceType}:{$resourceId}\");\n        if (!$version) {\n            \/\/ \u521d\u56de\u30a2\u30af\u30bb\u30b9\u6642\u306e\u51e6\u7406\n            return $this-&gt;initializeResourceCache($resourceType, $resourceId);\n        }\n\n        $cacheKey = \"data:{$resourceType}:{$resourceId}:v{$version}\";\n        $data = $this-&gt;redis-&gt;get($cacheKey);\n\n        if (!$data) {\n            \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30df\u30b9\u306e\u51e6\u7406\n            return $this-&gt;handleCacheMiss($resourceType, $resourceId);\n        }\n\n        return unserialize($data);\n    }\n\n    \/**\n     * \u30b5\u30fc\u30d3\u30b9\u9593\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u6574\u5408\u6027\u30c1\u30a7\u30c3\u30af\n     * @param string $resourceType \u30ea\u30bd\u30fc\u30b9\u30bf\u30a4\u30d7\n     * @param string $resourceId \u30ea\u30bd\u30fc\u30b9ID\n     * @return bool\n     *\/\n    public function validateCacheConsistency(\n        string $resourceType,\n        string $resourceId\n    ): bool {\n        $versions = $this-&gt;getAllServiceVersions($resourceType, $resourceId);\n\n        \/\/ \u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u4e0d\u4e00\u81f4\u30c1\u30a7\u30c3\u30af\n        $uniqueVersions = array_unique($versions);\n        if (count($uniqueVersions) &gt; 1) {\n            \/\/ \u4e0d\u6574\u5408\u306e\u691c\u51fa\u3068\u89e3\u6c7a\n            $this-&gt;resolveVersionConflict(\n                $resourceType,\n                $resourceId,\n                $versions\n            );\n            return false;\n        }\n\n        return true;\n    }\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u66f4\u65b0\u30a4\u30d9\u30f3\u30c8\u306e\u51e6\u7406\n     * @param array $event \u30a4\u30d9\u30f3\u30c8\u30c7\u30fc\u30bf\n     *\/\n    public function handleCacheUpdateEvent(array $event): void\n    {\n        if ($event['service'] === $this-&gt;serviceName) {\n            return; \/\/ \u81ea\u8eab\u304c\u767a\u884c\u3057\u305f\u30a4\u30d9\u30f3\u30c8\u306f\u7121\u8996\n        }\n\n        \/\/ \u30ed\u30fc\u30ab\u30eb\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u66f4\u65b0\n        $cacheKey = \"data:{$event['resource_type']}:{$event['resource_id']}:v{$event['version']}\";\n\n        \/\/ \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u30c7\u30fc\u30bf\u306e\u518d\u53d6\u5f97\n        if (!$this-&gt;redis-&gt;exists($cacheKey)) {\n            $this-&gt;fetchAndCacheResource(\n                $event['resource_type'],\n                $event['resource_id'],\n                $event['version']\n            );\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5b9f\u8df5\u7684\u306a\u30b7\u30ca\u30ea\u30aa\u3067\u52b9\u679c\u3092\u767a\u63ee\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5927\u898f\u6a21Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306e\u5229\u7528<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9ad8\u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u3078\u306e\u5bfe\u5fdc<\/li>\n\n\n\n<li>\u8907\u6570\u30b5\u30fc\u30d0\u30fc\u9593\u3067\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u7ba1\u7406<\/li>\n\n\n\n<li>API\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u52b9\u7387\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u74b0\u5883\u3067\u306e\u6d3b\u7528<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b5\u30fc\u30d3\u30b9\u9593\u306e\u30c7\u30fc\u30bf\u540c\u671f<\/li>\n\n\n\n<li>\u5206\u6563\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6574\u5408\u6027\u7ba1\u7406<\/li>\n\n\n\n<li>\u30a4\u30d9\u30f3\u30c8\u30c9\u30ea\u30d6\u30f3\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u66f4\u65b0<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u57fa\u306b\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8981\u4ef6\u306b\u5fdc\u3058\u3066\u9069\u5207\u306b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u3053\u3068\u3067\u3001\u52b9\u7387\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3088\u304f\u3042\u308b\u30c8\u30e9\u30d6\u30eb\u3068\u305d\u306e\u89e3\u6c7a\u7b56\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-21\">\u3088\u304f\u3042\u308b\u30c8\u30e9\u30d6\u30eb\u3068\u89e3\u6c7a\u7b56<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-22\">\u30e1\u30e2\u30ea\u4e0d\u8db3\u6642\u306e\u5bfe\u51e6\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u30e1\u30e2\u30ea\u95a2\u9023\u306e\u554f\u984c\u306b\u5bfe\u3059\u308b\u4f53\u7cfb\u7684\u306a\u5bfe\u51e6\u65b9\u6cd5\u3092\u5b9f\u88c5\u4f8b\u3068\u3068\u3082\u306b\u89e3\u8aac\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class RedisCacheTroubleshooter\n{\n    private $redis;\n    private $maxMemory;\n    private $warningThreshold = 0.8; \/\/ 80%\n    private $criticalThreshold = 0.9; \/\/ 90%\n\n    \/**\n     * \u30e1\u30e2\u30ea\u4f7f\u7528\u72b6\u6cc1\u306e\u76e3\u8996\u3068\u81ea\u52d5\u5bfe\u5fdc\n     * @return array \u76e3\u8996\u7d50\u679c\n     *\/\n    public function monitorMemoryUsage(): array\n    {\n        $info = $this-&gt;redis-&gt;info('memory');\n        $usedMemory = $info['used_memory'];\n        $maxMemory = $info['maxmemory'];\n\n        $usageRatio = $usedMemory \/ $maxMemory;\n        $status = $this-&gt;getMemoryStatus($usageRatio);\n\n        if ($status === 'critical') {\n            \/\/ \u30af\u30ea\u30c6\u30a3\u30ab\u30eb\u72b6\u614b\u3067\u306e\u7dca\u6025\u5bfe\u5fdc\n            $this-&gt;handleCriticalMemory();\n        } elseif ($status === 'warning') {\n            \/\/ \u8b66\u544a\u72b6\u614b\u3067\u306e\u4e88\u9632\u7684\u5bfe\u5fdc\n            $this-&gt;handleWarningMemory();\n        }\n\n        return [\n            'status' =&gt; $status,\n            'used_memory' =&gt; $usedMemory,\n            'max_memory' =&gt; $maxMemory,\n            'usage_ratio' =&gt; $usageRatio\n        ];\n    }\n\n    \/**\n     * \u30af\u30ea\u30c6\u30a3\u30ab\u30eb\u72b6\u614b\u306e\u30e1\u30e2\u30ea\u5bfe\u5fdc\n     *\/\n    private function handleCriticalMemory(): void\n    {\n        \/\/ 1. \u7dca\u6025\u30ad\u30e3\u30c3\u30b7\u30e5\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\n        $this-&gt;performEmergencyCleanup();\n\n        \/\/ 2. \u6709\u52b9\u671f\u9650\u306e\u77ed\u7e2e\n        $this-&gt;reduceTTLs();\n\n        \/\/ 3. \u5927\u304d\u306a\u30ad\u30fc\u306e\u7279\u5b9a\u3068\u524a\u9664\n        $this-&gt;removeLargeKeys();\n\n        \/\/ 4. \u30a2\u30e9\u30fc\u30c8\u306e\u767a\u884c\n        $this-&gt;notifyAdmins('CRITICAL: Redis\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c\u5371\u967a\u6c34\u6e96\u306b\u9054\u3057\u307e\u3057\u305f');\n    }\n\n    \/**\n     * \u7dca\u6025\u30ad\u30e3\u30c3\u30b7\u30e5\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u306e\u5b9f\u884c\n     *\/\n    private function performEmergencyCleanup(): void\n    {\n        \/\/ 1. \u6709\u52b9\u671f\u9650\u5207\u308c\u30ad\u30fc\u306e\u5373\u6642\u524a\u9664\n        $this-&gt;redis-&gt;executeCommand('EXPIRE', [], true);\n\n        \/\/ 2. \u30a2\u30af\u30bb\u30b9\u983b\u5ea6\u306e\u4f4e\u3044\u30ad\u30fc\u306e\u524a\u9664\n        $keys = $this-&gt;findLowAccessKeys();\n        foreach ($keys as $key) {\n            $this-&gt;redis-&gt;del($key);\n        }\n\n        \/\/ 3. \u4e00\u6642\u7684\u306a\u30ad\u30fc\u306e\u524a\u9664\n        $this-&gt;redis-&gt;eval(\"\n            local temp_keys = redis.call('KEYS', 'temp:*')\n            if #temp_keys &gt; 0 then\n                return redis.call('DEL', unpack(temp_keys))\n            end\n            return 0\n        \", 0);\n    }\n\n    \/**\n     * \u30a2\u30af\u30bb\u30b9\u983b\u5ea6\u306e\u4f4e\u3044\u30ad\u30fc\u306e\u7279\u5b9a\n     * @return array\n     *\/\n    private function findLowAccessKeys(): array\n    {\n        $lowAccessKeys = [];\n        $cursor = '0';\n\n        do {\n            $result = $this-&gt;redis-&gt;scan($cursor, [\n                'MATCH' =&gt; '*',\n                'COUNT' =&gt; 100\n            ]);\n\n            $cursor = $result[0];\n            $keys = $result[1];\n\n            foreach ($keys as $key) {\n                $idle = $this-&gt;redis-&gt;object('idletime', $key);\n                if ($idle &gt; 3600) { \/\/ 1\u6642\u9593\u4ee5\u4e0a\u30a2\u30af\u30bb\u30b9\u306e\u306a\u3044\u30ad\u30fc\n                    $lowAccessKeys[] = $key;\n                }\n            }\n        } while ($cursor !== '0');\n\n        return $lowAccessKeys;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-23\">\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6574\u5408\u6027\u304c\u5d29\u308c\u305f\u5834\u5408\u306e\u56de\u5fa9\u624b\u9806<\/h3>\n\n\n\n<p>\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6574\u5408\u6027\u554f\u984c\u306b\u5bfe\u3059\u308b\u56de\u5fa9\u624b\u9806\u306e\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CacheConsistencyManager\n{\n    private $redis;\n    private $db;\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6574\u5408\u6027\u30c1\u30a7\u30c3\u30af\u3068\u56de\u5fa9\n     * @param string $cacheKey \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param string $tableName \u30c6\u30fc\u30d6\u30eb\u540d\n     * @param int $id \u30ec\u30b3\u30fc\u30c9ID\n     * @return bool\n     *\/\n    public function verifyAndRecoverConsistency(\n        string $cacheKey,\n        string $tableName,\n        int $id\n    ): bool {\n        \/\/ 1. \u6574\u5408\u6027\u30c1\u30a7\u30c3\u30af\n        $cacheData = $this-&gt;redis-&gt;get($cacheKey);\n        $dbData = $this-&gt;db-&gt;query(\n            \"SELECT * FROM {$tableName} WHERE id = ?\",\n            [$id]\n        )-&gt;fetch();\n\n        if (!$this-&gt;isConsistent($cacheData, $dbData)) {\n            \/\/ 2. \u4e0d\u6574\u5408\u306e\u691c\u51fa\u3068\u4fee\u5fa9\n            $this-&gt;repairInconsistency($cacheKey, $dbData);\n            return false;\n        }\n\n        return true;\n    }\n\n    \/**\n     * \u5927\u898f\u6a21\u306a\u6574\u5408\u6027\u30c1\u30a7\u30c3\u30af\u3068\u4fee\u5fa9\n     * @param string $pattern \u30ad\u30fc\u30d1\u30bf\u30fc\u30f3\n     * @return array \u7d50\u679c\u30ec\u30dd\u30fc\u30c8\n     *\/\n    public function bulkConsistencyCheck(string $pattern): array\n    {\n        $report = [\n            'checked' =&gt; 0,\n            'inconsistent' =&gt; 0,\n            'repaired' =&gt; 0,\n            'failed' =&gt; 0\n        ];\n\n        $cursor = '0';\n        do {\n            $keys = $this-&gt;redis-&gt;scan($cursor, [\n                'MATCH' =&gt; $pattern,\n                'COUNT' =&gt; 100\n            ]);\n\n            foreach ($keys[1] as $key) {\n                $report['checked']++;\n\n                try {\n                    \/\/ \u30ad\u30fc\u304b\u3089\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u60c5\u5831\u3092\u62bd\u51fa\n                    [$table, $id] = $this-&gt;parseKey($key);\n\n                    if (!$this-&gt;verifyAndRecoverConsistency($key, $table, $id)) {\n                        $report['inconsistent']++;\n                        $report['repaired']++;\n                    }\n                } catch (Exception $e) {\n                    $report['failed']++;\n                    $this-&gt;logError($e);\n                }\n            }\n\n            $cursor = $keys[0];\n        } while ($cursor !== '0');\n\n        return $report;\n    }\n\n    \/**\n     * \u6574\u5408\u6027\u56de\u5fa9\u6642\u306e\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u6a5f\u80fd\n     * @param string $cacheKey \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\n     * @param array $oldData \u53e4\u3044\u30c7\u30fc\u30bf\n     * @param array $newData \u65b0\u3057\u3044\u30c7\u30fc\u30bf\n     *\/\n    public function recoveryWithRollback(\n        string $cacheKey,\n        array $oldData,\n        array $newData\n    ): void {\n        \/\/ \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u958b\u59cb\n        $this-&gt;redis-&gt;multi();\n\n        try {\n            \/\/ \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u4f5c\u6210\n            $this-&gt;redis-&gt;set(\n                $cacheKey . ':backup',\n                serialize($oldData),\n                ['EX' =&gt; 3600]\n            );\n\n            \/\/ \u65b0\u30c7\u30fc\u30bf\u306e\u8a2d\u5b9a\n            $this-&gt;redis-&gt;set($cacheKey, serialize($newData));\n\n            \/\/ \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u30b3\u30df\u30c3\u30c8\n            $this-&gt;redis-&gt;exec();\n        } catch (Exception $e) {\n            \/\/ \u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u306e\u5b9f\u884c\n            $this-&gt;redis-&gt;discard();\n            $this-&gt;performRollback($cacheKey);\n            throw $e;\n        }\n    }\n\n    \/**\n     * \u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6bb5\u968e\u7684\u306a\u518d\u69cb\u7bc9\n     * @param string $pattern \u30ad\u30fc\u30d1\u30bf\u30fc\u30f3\n     *\/\n    public function rebuildCacheGradually(string $pattern): void\n    {\n        $cursor = '0';\n        $batchSize = 100;\n        $processedKeys = 0;\n\n        do {\n            $keys = $this-&gt;redis-&gt;scan($cursor, [\n                'MATCH' =&gt; $pattern,\n                'COUNT' =&gt; $batchSize\n            ]);\n\n            foreach ($keys[1] as $key) {\n                try {\n                    \/\/ \u30ad\u30fc\u306e\u89e3\u6790\u3068\u30c7\u30fc\u30bf\u306e\u518d\u69cb\u7bc9\n                    [$table, $id] = $this-&gt;parseKey($key);\n                    $freshData = $this-&gt;fetchFreshData($table, $id);\n\n                    \/\/ \u4e00\u6642\u7684\u306a\u30ad\u30fc\u3092\u4f7f\u7528\u3057\u3066\u5b89\u5168\u306b\u66f4\u65b0\n                    $tempKey = $key . ':rebuild';\n                    $this-&gt;redis-&gt;set($tempKey, serialize($freshData));\n                    $this-&gt;redis-&gt;rename($tempKey, $key);\n\n                    $processedKeys++;\n                } catch (Exception $e) {\n                    $this-&gt;logError($e);\n                }\n\n                \/\/ \u8ca0\u8377\u5236\u5fa1\u306e\u305f\u3081\u306e\u4e00\u6642\u505c\u6b62\n                if ($processedKeys % 100 === 0) {\n                    usleep(100000); \/\/ 100ms\n                }\n            }\n\n            $cursor = $keys[0];\n        } while ($cursor !== '0');\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u5b9f\u88c5\u306b\u3088\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u554f\u984c\u306b\u52b9\u679c\u7684\u306b\u5bfe\u51e6\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e1\u30e2\u30ea\u4e0d\u8db3\u3078\u306e\u5bfe\u5fdc<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u81ea\u52d5\u7684\u306a\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u76e3\u8996<\/li>\n\n\n\n<li>\u6bb5\u968e\u7684\u306a\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u51e6\u7406<\/li>\n\n\n\n<li>\u7dca\u6025\u6642\u306e\u81ea\u52d5\u5bfe\u5fdc\u30e1\u30ab\u30cb\u30ba\u30e0<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u6574\u5408\u6027\u306e\u56de\u5fa9<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e0d\u6574\u5408\u306e\u691c\u51fa\u3068\u81ea\u52d5\u4fee\u5fa9<\/li>\n\n\n\n<li>\u5b89\u5168\u306a\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u30e1\u30ab\u30cb\u30ba\u30e0<\/li>\n\n\n\n<li>\u6bb5\u968e\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u518d\u69cb\u7bc9<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u554f\u984c\u306e\u89e3\u6c7a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u30a2\u30af\u30bb\u30b9\u30d1\u30bf\u30fc\u30f3\u306e\u5206\u6790<\/li>\n\n\n\n<li>\u52b9\u7387\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u66f4\u65b0<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5bfe\u7b56\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001Redis\u30ad\u30e3\u30c3\u30b7\u30e5\u30b7\u30b9\u30c6\u30e0\u306e\u5b89\u5b9a\u6027\u3068\u4fe1\u983c\u6027\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":{"0":"post-3300","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-php","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3300"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3300\/revisions"}],"predecessor-version":[{"id":3302,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3300\/revisions\/3302"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}