{"id":88047,"date":"2026-07-31T12:33:15","date_gmt":"2026-07-31T04:33:15","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/88047.html"},"modified":"2026-07-31T12:33:15","modified_gmt":"2026-07-31T04:33:15","slug":"%e5%8d%81%e4%b8%83%e3%80%81redis-%e6%a0%b8%e5%bf%83%e5%8e%9f%e7%90%86%e4%b8%8e%e6%9e%b6%e6%9e%84%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/88047.html","title":{"rendered":"\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3"},"content":{"rendered":"<p>Redis \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8e\u5185\u5b58\u7684\u9ad8\u6027\u80fd\u952e\u503c\u5b58\u50a8\u6570\u636e\u5e93&#xff0c;\u652f\u6301\u4e30\u5bcc\u7684\u6570\u636e\u7ed3\u6784\u7c7b\u578b&#xff0c;\u5355\u8282\u70b9 QPS \u53ef\u8fbe 10 \u4e07&#043;&#xff0c;\u8bfb\u5199\u5ef6\u8fdf\u4f4e\u81f3\u4e9a\u6beb\u79d2\u7ea7\u522b\u3002\u672c\u6587\u4ece Redis \u7684\u6838\u5fc3\u67b6\u6784\u3001\u6570\u636e\u7ed3\u6784\u3001\u6301\u4e45\u5316\u673a\u5236\u3001\u5185\u5b58\u7ba1\u7406\u3001\u9ad8\u53ef\u7528\u65b9\u6848\u7b49\u7ef4\u5ea6\u8fdb\u884c\u7cfb\u7edf\u6027\u7684\u6df1\u5ea6\u5256\u6790\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001Redis \u6982\u8ff0<\/h3>\n<h4>1.1 \u4ec0\u4e48\u662f Redis<\/h4>\n<p>Redis&#xff08;Remote Dictionary Server&#xff09;\u662f\u4e00\u4e2a\u57fa\u4e8e\u5185\u5b58\u7684\u952e\u503c\u5b58\u50a8\u7cfb\u7edf&#xff0c;\u7531 Salvatore Sanfilippo&#xff08;antirez&#xff09;\u4e8e 2009 \u5e74\u4f7f\u7528 C \u8bed\u8a00\u7f16\u5199\u3002\u5b83\u5c5e\u4e8e NoSQL \u6570\u636e\u5e93\u4e2d\u7684\u952e\u503c\u5b58\u50a8\u7c7b&#xff0c;\u4f46\u8fdc\u4e0d\u6b62\u662f\u4e00\u4e2a\u7b80\u5355\u7684 KV \u7f13\u5b58\u2014\u2014Redis \u63d0\u4f9b\u4e86 String\u3001List\u3001Hash\u3001Set\u3001ZSet\u3001Stream\u3001JSON\u3001Bitmap\u3001HyperLogLog\u3001Geospatial \u7b49\u4e30\u5bcc\u7684\u6570\u636e\u7ed3\u6784&#xff0c;\u4f7f\u5176\u53ef\u4ee5\u540c\u65f6\u4f5c\u4e3a\u6570\u636e\u5e93\u3001\u7f13\u5b58\u3001\u6d88\u606f\u4e2d\u95f4\u4ef6\u548c\u6d41\u5f0f\u5f15\u64ce\u4f7f\u7528\u3002<\/p>\n<h4>1.2 Redis \u7684\u6838\u5fc3\u5b9a\u4f4d<\/h4>\n<table>\n<tr>\u5b9a\u4f4d\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u5185\u5b58\u6570\u636e\u5e93<\/td>\n<td>\u6240\u6709\u6570\u636e\u5b58\u50a8\u5728\u5185\u5b58\u4e2d&#xff0c;\u63d0\u4f9b\u4e9a\u6beb\u79d2\u7ea7\u8bfb\u5199\u5ef6\u8fdf<\/td>\n<\/tr>\n<tr>\n<td>\u7f13\u5b58\u5f15\u64ce<\/td>\n<td>\u4f5c\u4e3a\u5173\u7cfb\u6570\u636e\u5e93\u524d\u7684\u7f13\u5b58\u5c42&#xff0c;\u5927\u5e45\u964d\u4f4e DB \u538b\u529b<\/td>\n<\/tr>\n<tr>\n<td>\u6d88\u606f\u4e2d\u95f4\u4ef6<\/td>\n<td>\u652f\u6301 Pub\/Sub \u53d1\u5e03\u8ba2\u9605\u548c Stream \u6d88\u606f\u6d41<\/td>\n<\/tr>\n<tr>\n<td>\u6d41\u5f0f\u5f15\u64ce<\/td>\n<td>Stream \u6570\u636e\u7c7b\u578b\u652f\u6301\u6d88\u606f\u6301\u4e45\u5316\u3001\u6d88\u8d39\u7ec4\u548c ACK \u673a\u5236<\/td>\n<\/tr>\n<tr>\n<td>\u5411\u91cf\u6570\u636e\u5e93<\/td>\n<td>Redis 7.4&#043; \u652f\u6301\u5411\u91cf\u96c6&#xff08;Vector Sets&#xff09;&#xff0c;\u53ef\u7528\u4e8e\u8bed\u4e49\u641c\u7d22\u548c RAG<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.3 Redis \u4e3a\u4ec0\u4e48\u5feb<\/h4>\n<p>Redis \u7684\u9ad8\u6027\u80fd\u662f\u4e94\u4e2a\u5c42\u9762\u534f\u540c\u4f5c\u7528\u7684\u7ed3\u679c&#xff1a;<\/p>\n<table>\n<tr>\u5c42\u9762\u6838\u5fc3\u673a\u5236\u5bf9\u6027\u80fd\u7684\u8d21\u732e<\/tr>\n<tbody>\n<tr>\n<td>\u5b58\u50a8\u4ecb\u8d28<\/td>\n<td>\u7eaf\u5185\u5b58\u64cd\u4f5c<\/td>\n<td>\u6d88\u9664\u78c1\u76d8 IO \u74f6\u9888&#xff0c;\u5ef6\u8fdf\u4ece ms \u7ea7\u964d\u5230 \u03bcs \u7ea7<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u7ed3\u6784<\/td>\n<td>\u7cbe\u5fc3\u8bbe\u8ba1\u7684\u5e95\u5c42\u7f16\u7801<\/td>\n<td>\u540c\u4e00 API \u6839\u636e\u6570\u636e\u89c4\u6a21\u81ea\u52a8\u5207\u6362\u6700\u4f18\u7f16\u7801<\/td>\n<\/tr>\n<tr>\n<td>IO \u6a21\u578b<\/td>\n<td>epoll \u591a\u8def\u590d\u7528<\/td>\n<td>\u5355\u7ebf\u7a0b\u5904\u7406\u6570\u4e07\u5e76\u53d1\u8fde\u63a5&#xff0c;\u907f\u514d\u7ebf\u6027\u626b\u63cf<\/td>\n<\/tr>\n<tr>\n<td>\u7ebf\u7a0b\u6a21\u578b<\/td>\n<td>\u6838\u5fc3\u5355\u7ebf\u7a0b<\/td>\n<td>\u65e0\u9501\u8bbe\u8ba1&#xff0c;\u6d88\u9664\u4e0a\u4e0b\u6587\u5207\u6362\u548c\u7ade\u4e89\u5f00\u9500<\/td>\n<\/tr>\n<tr>\n<td>\u534f\u8bae\u8bbe\u8ba1<\/td>\n<td>RESP \u534f\u8bae<\/td>\n<td>\u6587\u672c\u534f\u8bae\u89e3\u6790\u5feb\u901f&#xff0c;\u652f\u6301 Pipeline \u6279\u91cf\u64cd\u4f5c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e8c\u3001Redis \u6838\u5fc3\u67b6\u6784<\/h3>\n<h4>2.1 \u6574\u4f53\u67b6\u6784\u5206\u5c42<\/h4>\n<p>Redis \u7684\u67b6\u6784\u53ef\u4ee5\u5206\u4e3a\u56db\u5c42&#xff1a;<\/p>\n<p>\u5ba2\u6237\u7aef\u5c42&#xff1a;\u5ba2\u6237\u7aef\u901a\u8fc7 RESP&#xff08;Redis Serialization Protocol&#xff09;\u534f\u8bae\u4e0e\u670d\u52a1\u7aef\u901a\u4fe1\u3002RESP \u662f\u4e00\u79cd\u6587\u672c\u534f\u8bae&#xff0c;\u683c\u5f0f\u7b80\u5355\u3001\u89e3\u6790\u5feb\u901f&#xff0c;\u652f\u6301\u4e94\u79cd\u6570\u636e\u7c7b\u578b&#xff1a;\u7b80\u5355\u5b57\u7b26\u4e32&#xff08;&#043;&#xff09;\u3001\u9519\u8bef&#xff08;-&#xff09;\u3001\u6574\u6570&#xff08;:&#xff09;\u3001\u6279\u91cf\u5b57\u7b26\u4e32&#xff08;$&#xff09;\u548c\u6570\u7ec4&#xff08;*&#xff09;\u3002<\/p>\n<p>\u7f51\u7edc\u5c42&#xff1a;Redis \u4f7f\u7528\u57fa\u4e8e epoll \u7684 IO \u591a\u8def\u590d\u7528\u6a21\u578b&#xff0c;\u5355\u7ebf\u7a0b\u5373\u53ef\u5904\u7406\u6570\u4e07\u4e2a\u5e76\u53d1\u8fde\u63a5\u3002\u6838\u5fc3\u7ec4\u4ef6 aeEventLoop \u8d1f\u8d23\u76d1\u542c\u6587\u4ef6\u63cf\u8ff0\u7b26\u4e8b\u4ef6&#xff08;\u53ef\u8bfb\/\u53ef\u5199\/\u8d85\u65f6&#xff09;&#xff0c;\u5e76\u5c06\u4e8b\u4ef6\u5206\u53d1\u7ed9\u5bf9\u5e94\u7684\u5904\u7406\u5668\u3002<\/p>\n<p>\u6838\u5fc3\u5c42&#xff1a;\u5305\u542b\u547d\u4ee4\u5904\u7406\u5668\u3001\u6570\u636e\u5e93\u5b57\u5178\u3001\u8fc7\u671f\u5b57\u5178\u548c\u5185\u5b58\u5206\u914d\u5668\u3002\u6bcf\u4e2a Redis \u5b9e\u4f8b\u9ed8\u8ba4\u6709 16 \u4e2a\u6570\u636e\u5e93&#xff08;\u7f16\u53f7 0-15&#xff09;&#xff0c;\u6bcf\u4e2a\u6570\u636e\u5e93\u7ef4\u62a4\u4e24\u4e2a\u5b57\u5178&#xff1a;<\/p>\n<ul>\n<li>\u952e\u7a7a\u95f4\u5b57\u5178&#xff08;key space dict&#xff09;&#xff1a;\u5b58\u50a8\u6240\u6709\u952e\u503c\u5bf9&#xff0c;key \u4e3a\u5b57\u7b26\u4e32&#xff0c;value \u4e3a redisObject<\/li>\n<li>\u8fc7\u671f\u5b57\u5178&#xff08;expires dict&#xff09;&#xff1a;\u5b58\u50a8\u952e\u7684\u8fc7\u671f\u65f6\u95f4\u6233&#xff0c;key \u6307\u5411\u952e\u7a7a\u95f4\u4e2d\u7684\u540c\u4e00\u4e2a\u952e&#xff0c;value \u4e3a Unix \u65f6\u95f4\u6233<\/li>\n<\/ul>\n<p>\u6301\u4e45\u5316\u5c42&#xff1a;RDB \u5feb\u7167\u548c AOF \u65e5\u5fd7\u4e24\u79cd\u673a\u5236\u786e\u4fdd\u6570\u636e\u6301\u4e45\u6027\u3002<\/p>\n<h4>2.2 \u5355\u7ebf\u7a0b\u6a21\u578b\u89e3\u6790<\/h4>\n<p>Redis \u7684\u6838\u5fc3\u547d\u4ee4\u5904\u7406\u662f\u5355\u7ebf\u7a0b\u7684&#xff08;Redis 6.0 \u4e4b\u524d\u5b8c\u5168\u5355\u7ebf\u7a0b&#xff0c;6.0 \u5f15\u5165\u591a\u7ebf\u7a0b\u4ec5\u7528\u4e8e\u7f51\u7edc IO \u89e3\u6790&#xff09;&#xff1a;<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502               Redis \u4e8b\u4ef6\u5faa\u73af                   \u2502<br \/>\n\u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u2502<br \/>\n\u2502  \u2502 \u6587\u4ef6\u4e8b\u4ef6 \u2502  \u2502 \u65f6\u95f4\u4e8b\u4ef6 \u2502  \u2502 \u547d\u4ee4\u6267\u884c\u5668   \u2502  \u2502<br \/>\n\u2502  \u2502 (epoll) \u2502  \u2502(serverCron)\u2502 \u2502 (processCmd)\u2502  \u2502<br \/>\n\u2502  \u2514\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2518  \u2514\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2518  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2518  \u2502<br \/>\n\u2502       \u2502            \u2502               \u2502          \u2502<br \/>\n\u2502  \u8bfb\u5199\u5ba2\u6237\u7aef\u6570\u636e  \u5b9a\u65f6\u4efb\u52a1\u8c03\u5ea6    \u6267\u884c\u5177\u4f53\u547d\u4ee4    \u2502<br \/>\n\u2502  \u534f\u8bae\u89e3\u6790\/\u7f16\u7801  \u8fc7\u671fkey\u6e05\u7406    \u6570\u636e\u64cd\u4f5c         \u2502<br \/>\n\u2502  \u590d\u5236\u540c\u6b65      AOF\u91cd\u5199\u89e6\u53d1    \u6301\u4e45\u5316            \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u4e3a\u4ec0\u4e48\u5355\u7ebf\u7a0b\u8fd8\u8fd9\u4e48\u5feb&#xff1f;<\/p>\n<li>\u7eaf\u5185\u5b58\u64cd\u4f5c&#xff1a;\u6240\u6709\u64cd\u4f5c\u90fd\u5728\u5185\u5b58\u4e2d\u5b8c\u6210&#xff0c;CPU \u662f\u552f\u4e00\u7684\u6027\u80fd\u74f6\u9888&#xff0c;\u5355\u7ebf\u7a0b\u907f\u514d\u4e86\u591a\u7ebf\u7a0b\u7684\u9501\u7ade\u4e89\u548c\u4e0a\u4e0b\u6587\u5207\u6362<\/li>\n<li>\u9ad8\u6548\u6570\u636e\u7ed3\u6784&#xff1a;\u7cbe\u5fc3\u8bbe\u8ba1\u7684\u8df3\u8868\u3001\u538b\u7f29\u5217\u8868\u3001\u54c8\u5e0c\u8868\u7b49&#xff0c;\u4fdd\u8bc1\u64cd\u4f5c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(1) \u6216 O(logN)<\/li>\n<li>IO \u591a\u8def\u590d\u7528&#xff1a;epoll \u673a\u5236\u4f7f\u5355\u7ebf\u7a0b\u80fd\u540c\u65f6\u76d1\u542c\u6570\u5343\u4e2a\u8fde\u63a5\u7684 IO \u4e8b\u4ef6<\/li>\n<li>RESP \u534f\u8bae\u7b80\u5355&#xff1a;\u6587\u672c\u534f\u8bae\u89e3\u6790\u5f00\u9500\u6781\u4f4e<\/li>\n<li>Pipeline \u652f\u6301&#xff1a;\u5ba2\u6237\u7aef\u53ef\u4ee5\u6279\u91cf\u53d1\u9001\u547d\u4ee4&#xff0c;\u51cf\u5c11\u7f51\u7edc RTT<\/li>\n<p>Redis 6.0 \u591a\u7ebf\u7a0b\u6539\u52a8&#xff1a;Redis 6.0 \u5f15\u5165\u4e86\u591a\u7ebf\u7a0b\u7f51\u7edc IO&#xff08;\u9ed8\u8ba4\u5173\u95ed&#xff09;&#xff0c;\u5c06\u534f\u8bae\u89e3\u6790\u548c\u54cd\u5e94\u7f16\u7801\u4ece\u4e3b\u7ebf\u7a0b\u5378\u8f7d\u5230 IO \u7ebf\u7a0b&#xff0c;\u4f46\u547d\u4ee4\u6267\u884c\u4ecd\u7136\u662f\u5355\u7ebf\u7a0b\u7684&#xff0c;\u4fdd\u8bc1\u539f\u5b50\u6027\u4e0d\u53d8\u3002<\/p>\n<h4>2.3 RESP \u534f\u8bae<\/h4>\n<p>RESP \u534f\u8bae\u662f Redis \u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u901a\u4fe1\u7684\u57fa\u7840&#xff1a;<\/p>\n<p># \u5ba2\u6237\u7aef\u8bf7\u6c42&#xff08;RESP \u6570\u7ec4\u683c\u5f0f&#xff09;<br \/>\n*3\\\\r\\\\n$3\\\\r\\\\nSET\\\\r\\\\n$5\\\\r\\\\nmykey\\\\r\\\\n$7\\\\r\\\\nmyvalue\\\\r\\\\n<\/p>\n<p># \u670d\u52a1\u7aef\u54cd\u5e94<br \/>\n&#043;OK\\\\r\\\\n                    # \u7b80\u5355\u5b57\u7b26\u4e32<br \/>\n-Error message\\\\r\\\\n         # \u9519\u8bef<br \/>\n:1000\\\\r\\\\n                  # \u6574\u6570<br \/>\n$5\\\\r\\\\nhello\\\\r\\\\n            # \u6279\u91cf\u5b57\u7b26\u4e32<br \/>\n*2\\\\r\\\\n$3\\\\r\\\\nfoo\\\\r\\\\n$3\\\\r\\\\nbar\\\\r\\\\n  # \u6570\u7ec4<\/p>\n<p># RESP3 \u65b0\u589e\u7c7b\u578b&#xff08;Redis 6.0&#043;&#xff09;<br \/>\n%2\\\\r\\\\n                     # Map \u7c7b\u578b<br \/>\n~3\\\\r\\\\n                     # Set \u7c7b\u578b<br \/>\n&#061;15\\\\r\\\\n&#8230;txt\\\\r\\\\n          # Verbatim \u5b57\u7b26\u4e32<\/p>\n<hr \/>\n<h3>\u4e09\u3001Redis \u6570\u636e\u7ed3\u6784<\/h3>\n<h4>3.1 \u4e24\u5c42\u67b6\u6784\u8bbe\u8ba1<\/h4>\n<p>Redis \u6700\u7cbe\u5999\u7684\u8bbe\u8ba1\u4e4b\u4e00\u662f&#034;\u4e24\u5c42\u67b6\u6784&#034;\u2014\u2014\u5bf9\u5916\u66b4\u9732 5 \u79cd\u6838\u5fc3\u903b\u8f91\u6570\u636e\u7c7b\u578b&#xff0c;\u5e95\u5c42\u6839\u636e\u6570\u636e\u91cf\u548c\u5143\u7d20\u5927\u5c0f\u81ea\u52a8\u9009\u62e9\u6700\u4f18\u7684\u7269\u7406\u7f16\u7801\u3002\u8fd9\u4e24\u5c42\u901a\u8fc7 redisObject \u7ed3\u6784\u4f53\u6865\u63a5&#xff1a;<\/p>\n<p><span class=\"token keyword\">typedef<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">redisObject<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">unsigned<\/span> type<span class=\"token operator\">:<\/span><span class=\"token number\">4<\/span><span class=\"token punctuation\">;<\/span>      <span class=\"token comment\">\/\/ \u903b\u8f91\u7c7b\u578b&#xff08;STRING\/LIST\/HASH\/SET\/ZSET&#xff09;<\/span><br \/>\n    <span class=\"token keyword\">unsigned<\/span> encoding<span class=\"token operator\">:<\/span><span class=\"token number\">4<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u7269\u7406\u7f16\u7801&#xff08;int\/embstr\/raw\/hashtable\/skiplist&#8230;&#xff09;<\/span><br \/>\n    <span class=\"token keyword\">unsigned<\/span> lru<span class=\"token operator\">:<\/span><span class=\"token number\">24<\/span><span class=\"token punctuation\">;<\/span>      <span class=\"token comment\">\/\/ LRU \u6dd8\u6c70\u4fe1\u606f&#xff08;\u9ad816\u4f4d\u4e3a\u65f6\u95f4&#xff0c;\u4f4e8\u4f4d\u4e3a\u9891\u7387&#xff09;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> refcount<span class=\"token punctuation\">;<\/span>         <span class=\"token comment\">\/\/ \u5f15\u7528\u8ba1\u6570<\/span><br \/>\n    <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>ptr<span class=\"token punctuation\">;<\/span>            <span class=\"token comment\">\/\/ \u6307\u5411\u5e95\u5c42\u6570\u636e\u7ed3\u6784\u7684\u6307\u9488<\/span><br \/>\n<span class=\"token punctuation\">}<\/span> robj<span class=\"token punctuation\">;<\/span><\/p>\n<h4>3.2 \u903b\u8f91\u7c7b\u578b\u4e0e\u7269\u7406\u7f16\u7801\u6620\u5c04<\/h4>\n<table>\n<tr>\u903b\u8f91\u7c7b\u578b\u5e95\u5c42\u7269\u7406\u7f16\u7801\u5207\u6362\u6761\u4ef6&#xff08;Redis 7.x \u9ed8\u8ba4&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>String<\/td>\n<td>int<\/td>\n<td>\u503c\u4e3a 64 \u4f4d\u6574\u6570<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>embstr<\/td>\n<td>\u5b57\u7b26\u4e32\u957f\u5ea6 \u2264 44 \u5b57\u8282<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>raw&#xff08;SDS&#xff09;<\/td>\n<td>\u5b57\u7b26\u4e32\u957f\u5ea6 &gt; 44 \u5b57\u8282<\/td>\n<\/tr>\n<tr>\n<td>List<\/td>\n<td>listpack<\/td>\n<td>\u5143\u7d20\u6570 \u2264 128 \u4e14\u6bcf\u4e2a\u5143\u7d20 \u2264 64 \u5b57\u8282<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>quicklist<\/td>\n<td>\u8d85\u51fa\u4e0a\u8ff0\u9608\u503c<\/td>\n<\/tr>\n<tr>\n<td>Hash<\/td>\n<td>listpack<\/td>\n<td>\u952e\u503c\u5bf9\u6570 \u2264 128 \u4e14\u6bcf\u4e2a\u503c \u2264 64 \u5b57\u8282<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>hashtable<\/td>\n<td>\u8d85\u51fa\u4e0a\u8ff0\u9608\u503c<\/td>\n<\/tr>\n<tr>\n<td>Set<\/td>\n<td>intset<\/td>\n<td>\u6240\u6709\u5143\u7d20\u5747\u4e3a\u6574\u6570\u4e14\u5143\u7d20\u6570 \u2264 512<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>listpack<\/td>\n<td>\u5143\u7d20\u6570 \u2264 128 \u4e14\u6bcf\u4e2a\u5143\u7d20 \u2264 64 \u5b57\u8282<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>hashtable<\/td>\n<td>\u8d85\u51fa\u4e0a\u8ff0\u9608\u503c<\/td>\n<\/tr>\n<tr>\n<td>ZSet<\/td>\n<td>listpack<\/td>\n<td>\u5143\u7d20\u6570 \u2264 128 \u4e14\u6bcf\u4e2a\u5143\u7d20 \u2264 64 \u5b57\u8282<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>skiplist &#043; hashtable<\/td>\n<td>\u8d85\u51fa\u4e0a\u8ff0\u9608\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4ee5\u4e0a\u9608\u503c\u5747\u53ef\u901a\u8fc7\u914d\u7f6e\u8c03\u6574&#xff0c;\u5982 list-max-listpack-size\u3001set-max-listpack-entries \u7b49\u3002<\/p>\n<h4>3.3 \u6838\u5fc3\u5e95\u5c42\u6570\u636e\u7ed3\u6784\u8be6\u89e3<\/h4>\n<h5>3.3.1 SDS&#xff08;Simple Dynamic String&#xff09;\u7b80\u5355\u52a8\u6001\u5b57\u7b26\u4e32<\/h5>\n<p>Redis \u6ca1\u6709\u4f7f\u7528 C \u8bed\u8a00\u539f\u751f\u5b57\u7b26\u4e32&#xff0c;\u800c\u662f\u81ea\u5df1\u5b9e\u73b0\u4e86 SDS&#xff1a;<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sdshdr<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> len<span class=\"token punctuation\">;<\/span>      <span class=\"token comment\">\/\/ \u5df2\u4f7f\u7528\u957f\u5ea6<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> free<span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/ \u5269\u4f59\u53ef\u7528\u957f\u5ea6<\/span><br \/>\n    <span class=\"token keyword\">char<\/span> buf<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u5b57\u7b26\u6570\u7ec4<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u76f8\u6bd4 C \u5b57\u7b26\u4e32\u7684\u4f18\u52bf&#xff1a;<\/p>\n<table>\n<tr>\u7279\u6027C \u5b57\u7b26\u4e32SDS<\/tr>\n<tbody>\n<tr>\n<td>\u83b7\u53d6\u957f\u5ea6<\/td>\n<td>O(N) \u9700\u904d\u5386<\/td>\n<td>O(1) \u76f4\u63a5\u8bfb\u53d6 len \u5b57\u6bb5<\/td>\n<\/tr>\n<tr>\n<td>\u4e8c\u8fdb\u5236\u5b89\u5168<\/td>\n<td>\u4e0d\u5b89\u5168&#xff08;\\\\0 \u4e3a\u7ec8\u6b62\u7b26&#xff09;<\/td>\n<td>\u5b89\u5168&#xff08;\u7528 len \u5224\u65ad\u957f\u5ea6&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u4fee\u6539\u8ffd\u52a0<\/td>\n<td>\u53ef\u80fd\u6ea2\u51fa<\/td>\n<td>\u81ea\u52a8\u6269\u5bb9&#xff08;\u5148\u68c0\u67e5\u7a7a\u95f4\u4e0d\u8db3\u518d\u5206\u914d&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5206\u914d<\/td>\n<td>\u6bcf\u6b21\u4fee\u6539\u90fd\u91cd\u65b0\u5206\u914d<\/td>\n<td>\u7a7a\u95f4\u9884\u5206\u914d &#043; \u60f0\u6027\u91ca\u653e&#xff0c;\u51cf\u5c11\u5206\u914d\u6b21\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6269\u5bb9\u7b56\u7565&#xff1a;<\/p>\n<ul>\n<li>\u4fee\u6539\u540e\u957f\u5ea6 &lt; 1MB&#xff1a;\u5206\u914d 2 \u500d\u7a7a\u95f4 &#043; 1 \u5b57\u8282<\/li>\n<li>\u4fee\u6539\u540e\u957f\u5ea6 \u2265 1MB&#xff1a;\u5206\u914d\u5f53\u524d\u957f\u5ea6 &#043; 1MB &#043; 1 \u5b57\u8282<\/li>\n<\/ul>\n<h5>3.3.2 \u8df3\u8868&#xff08;Skip List&#xff09;<\/h5>\n<p>\u8df3\u8868\u662f ZSet \u5e95\u5c42\u7684\u6838\u5fc3\u6392\u5e8f\u5f15\u64ce&#xff0c;\u91c7\u7528&#034;\u7a7a\u95f4\u6362\u65f6\u95f4&#034;\u601d\u60f3&#xff0c;\u901a\u8fc7\u591a\u5c42\u7d22\u5f15\u5c06\u94fe\u8868 O(N) \u7684\u67e5\u627e\u4f18\u5316\u5230 O(logN)&#xff1a;<\/p>\n<p>Level 3:  1 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt; 9<br \/>\nLevel 2:  1 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt; 4 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt; 9<br \/>\nLevel 1:  1 \u2500\u2500\u2500&gt; 3 \u2500\u2500\u2500\u2500&gt; 4 \u2500\u2500\u2500&gt; 6 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt; 9<br \/>\nLevel 0:  1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt; 5 -&gt; 6 -&gt; 7 -&gt; 8 -&gt; 9<\/p>\n<p>\u67e5\u627e\u5143\u7d20 7 \u7684\u8def\u5f84&#xff1a;Level 3: 1 \u2192 9&#xff08;9&gt;7&#xff0c;\u4e0b\u964d&#xff09;\u2192 Level 2: 1 \u2192 4 \u2192 9&#xff08;9&gt;7&#xff0c;\u4e0b\u964d&#xff09;\u2192 Level 1: 4 \u2192 6 \u2192 9&#xff08;9&gt;7&#xff0c;\u4e0b\u964d&#xff09;\u2192 Level 0: 6 \u2192 7&#xff08;\u627e\u5230&#xff01;&#xff09;&#xff0c;\u53ea\u8bbf\u95ee\u4e86 7 \u4e2a\u8282\u70b9\u3002<\/p>\n<p><span class=\"token keyword\">typedef<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">zskiplistNode<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    sds ele<span class=\"token punctuation\">;<\/span>                         <span class=\"token comment\">\/\/ \u6210\u5458\u503c<\/span><br \/>\n    <span class=\"token keyword\">double<\/span> score<span class=\"token punctuation\">;<\/span>                    <span class=\"token comment\">\/\/ \u6392\u5e8f\u5206\u6570<\/span><br \/>\n    <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">zskiplistNode<\/span> <span class=\"token operator\">*<\/span>backward<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u540e\u9000\u6307\u9488<\/span><br \/>\n    <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">zskiplistLevel<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">zskiplistNode<\/span> <span class=\"token operator\">*<\/span>forward<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u524d\u8fdb\u6307\u9488<\/span><br \/>\n        <span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> span<span class=\"token punctuation\">;<\/span>             <span class=\"token comment\">\/\/ \u8de8\u5ea6&#xff08;\u7528\u4e8e\u6392\u540d\u8ba1\u7b97&#xff09;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span> level<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span>                       <span class=\"token comment\">\/\/ \u67d4\u6027\u6570\u7ec4&#xff0c;\u5c42\u6570\u968f\u673a<\/span><br \/>\n<span class=\"token punctuation\">}<\/span> zskiplistNode<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4e3a\u4ec0\u4e48\u9009\u8df3\u8868\u4e0d\u9009\u7ea2\u9ed1\u6811&#xff1f;<\/p>\n<table>\n<tr>\u7ef4\u5ea6\u8df3\u8868\u7ea2\u9ed1\u6811<\/tr>\n<tbody>\n<tr>\n<td>\u4ee3\u7801\u590d\u6742\u5ea6<\/td>\n<td>\u7ea6 300 \u884c&#xff0c;\u5b9e\u73b0\u7b80\u5355<\/td>\n<td>500&#043; \u884c&#xff0c;\u65cb\u8f6c\u64cd\u4f5c\u590d\u6742<\/td>\n<\/tr>\n<tr>\n<td>\u8303\u56f4\u67e5\u8be2<\/td>\n<td>\u627e\u5230\u8d77\u70b9\u540e\u6cbf\u94fe\u8868\u904d\u5386\u5373\u53ef<\/td>\n<td>\u9700\u8981\u4e2d\u5e8f\u904d\u5386&#xff0c;\u5b9e\u73b0\u590d\u6742<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u5f00\u9500<\/td>\n<td>\u5e73\u5747\u6bcf\u4e2a\u8282\u70b9 1.33 \u4e2a\u6307\u9488&#xff08;p&#061;0.25&#xff09;<\/td>\n<td>\u56fa\u5b9a 3 \u4e2a\u6307\u9488<\/td>\n<\/tr>\n<tr>\n<td>\u5e76\u53d1\u53cb\u597d<\/td>\n<td>\u5c40\u90e8\u4fee\u6539\u4e0d\u5f71\u54cd\u5168\u5c40\u7ed3\u6784<\/td>\n<td>\u65cb\u8f6c\u64cd\u4f5c\u5f71\u54cd\u5168\u5c40<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>3.3.3 \u538b\u7f29\u5217\u8868&#xff08;Ziplist \/ Listpack&#xff09;<\/h5>\n<p>\u538b\u7f29\u5217\u8868\u662f\u4e00\u6bb5\u8fde\u7eed\u5185\u5b58\u5757&#xff0c;\u53bb\u9664\u4e86\u6307\u9488\u5f00\u9500&#xff0c;\u901a\u8fc7\u6781\u81f4\u7d27\u51d1\u7684\u7f16\u7801\u65b9\u5f0f\u8282\u7701\u5185\u5b58&#xff1a;<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 zlbytes  \u2502 zltail   \u2502 zllen    \u2502 entry1   \u2502 &#8230;  \u2502<br \/>\n\u2502 4 bytes  \u2502 4 bytes  \u2502 2 bytes  \u2502 \u53d8\u957f\u7f16\u7801  \u2502      \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<ul>\n<li>zlbytes&#xff1a;\u6574\u4e2a\u5217\u8868\u5360\u7528\u7684\u5b57\u8282\u6570<\/li>\n<li>zltail&#xff1a;\u5c3e\u8282\u70b9\u7684\u504f\u79fb\u91cf&#xff0c;\u65b9\u4fbf\u4ece\u5c3e\u90e8\u904d\u5386<\/li>\n<li>zllen&#xff1a;\u8282\u70b9\u6570\u91cf<\/li>\n<li>entry&#xff1a;\u6bcf\u4e2a\u8282\u70b9\u5305\u542b prevlen&#xff08;\u524d\u4e00\u8282\u70b9\u957f\u5ea6&#xff09;&#043; encoding&#xff08;\u7f16\u7801\u65b9\u5f0f&#xff09;&#043; data&#xff08;\u6570\u636e&#xff09;<\/li>\n<\/ul>\n<p>\u7f3a\u70b9&#xff1a;\u8fde\u9501\u66f4\u65b0\u95ee\u9898\u2014\u2014\u5f53\u63d2\u5165\/\u5220\u9664\u8282\u70b9\u5bfc\u81f4\u524d\u4e00\u8282\u70b9\u957f\u5ea6\u53d8\u5316\u65f6&#xff0c;\u540e\u7eed\u6240\u6709\u8282\u70b9\u7684 prevlen \u90fd\u9700\u8981\u91cd\u65b0\u7f16\u7801&#xff0c;\u6700\u574f\u60c5\u51b5 O(N)\u3002Redis 7.0 \u5f15\u5165 listpack \u66ff\u4ee3 ziplist&#xff0c;\u901a\u8fc7\u5728\u6bcf\u4e2a\u8282\u70b9\u4e2d\u8bb0\u5f55\u603b\u957f\u5ea6\u6765\u89e3\u51b3\u8fde\u9501\u66f4\u65b0\u95ee\u9898\u3002<\/p>\n<h5>3.3.4 \u6574\u6570\u96c6\u5408&#xff08;IntSet&#xff09;<\/h5>\n<p>IntSet \u662f\u4e13\u95e8\u5b58\u50a8\u7eaf\u6574\u6570\u96c6\u5408\u7684\u7d27\u51d1\u7ed3\u6784&#xff1a;<\/p>\n<p><span class=\"token keyword\">typedef<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">intset<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">uint32_t<\/span> encoding<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u7f16\u7801\u65b9\u5f0f&#xff08;INTSET_ENC_INT16\/32\/64&#xff09;<\/span><br \/>\n    <span class=\"token class-name\">uint32_t<\/span> length<span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ \u5143\u7d20\u4e2a\u6570<\/span><br \/>\n    <span class=\"token class-name\">int8_t<\/span> contents<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u6709\u5e8f\u6574\u6570\u6570\u7ec4<\/span><br \/>\n<span class=\"token punctuation\">}<\/span> intset<span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>\u6240\u6709\u5143\u7d20\u5747\u4e3a\u6574\u6570\u65f6\u624d\u4f7f\u7528 intset<\/li>\n<li>\u5143\u7d20\u6309\u503c\u6392\u5e8f\u5b58\u50a8&#xff0c;\u652f\u6301\u4e8c\u5206\u67e5\u627e<\/li>\n<li>\u81ea\u52a8\u5347\u7ea7\u7f16\u7801&#xff1a;\u5f53\u63d2\u5165\u66f4\u5927\u8303\u56f4\u7684\u6574\u6570\u65f6&#xff0c;\u4ece int16 \u5347\u7ea7\u5230 int32 \u6216 int64<\/li>\n<\/ul>\n<h4>3.4 \u4e94\u79cd\u6838\u5fc3\u903b\u8f91\u7c7b\u578b\u8be6\u89e3<\/h4>\n<h5>3.4.1 String&#xff08;\u5b57\u7b26\u4e32&#xff09;<\/h5>\n<p>String \u662f\u6700\u57fa\u7840\u4e5f\u662f\u6700\u7075\u6d3b\u7684\u7c7b\u578b&#xff0c;\u53ef\u4ee5\u5b58\u50a8\u5b57\u7b26\u4e32\u3001\u6574\u6570\u6216\u6d6e\u70b9\u6570&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u57fa\u672c\u64cd\u4f5c<\/span><br \/>\nSET user:1:name <span class=\"token string\">&#034;\u5f20\u4e09&#034;<\/span>           <span class=\"token comment\"># \u8bbe\u7f6e\u503c<\/span><br \/>\nGET user:1:name                  <span class=\"token comment\"># \u83b7\u53d6\u503c \u2192 &#034;\u5f20\u4e09&#034;<\/span><br \/>\nINCR page:views                  <span class=\"token comment\"># \u539f\u5b50\u9012\u589e&#xff08;\u8ba1\u6570\u5668&#xff09;<\/span><br \/>\nSET session:token <span class=\"token string\">&#034;abc&#034;<\/span> EX <span class=\"token number\">3600<\/span>  <span class=\"token comment\"># \u8bbe\u7f6e\u503c\u5e76\u6307\u5b9a\u8fc7\u671f\u65f6\u95f4&#xff08;\u79d2&#xff09;<\/span><br \/>\nSETNX lock:order <span class=\"token string\">&#034;1&#034;<\/span>             <span class=\"token comment\"># \u4ec5\u5f53 key \u4e0d\u5b58\u5728\u65f6\u8bbe\u7f6e&#xff08;\u5206\u5e03\u5f0f\u9501&#xff09;<\/span><\/p>\n<p>\u5178\u578b\u5e94\u7528&#xff1a;\u7f13\u5b58\u70ed\u70b9\u6570\u636e\u3001\u5206\u5e03\u5f0f\u9501\u3001\u8ba1\u6570\u5668\u3001Session \u5171\u4eab\u3001\u5206\u5e03\u5f0f ID \u751f\u6210<\/p>\n<h5>3.4.2 Hash&#xff08;\u54c8\u5e0c&#xff09;<\/h5>\n<p>Hash \u9002\u5408\u5b58\u50a8\u5bf9\u8c61&#xff0c;\u4e00\u4e2a key \u6620\u5c04\u591a\u4e2a field-value&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u57fa\u672c\u64cd\u4f5c<\/span><br \/>\nHSET user:1 name <span class=\"token string\">&#034;\u5f20\u4e09&#034;<\/span> age <span class=\"token number\">28<\/span> city <span class=\"token string\">&#034;\u5317\u4eac&#034;<\/span>  <span class=\"token comment\"># \u8bbe\u7f6e\u591a\u4e2a\u5b57\u6bb5<\/span><br \/>\nHGET user:1 name                            <span class=\"token comment\"># \u83b7\u53d6\u5355\u4e2a\u5b57\u6bb5 \u2192 &#034;\u5f20\u4e09&#034;<\/span><br \/>\nHMGET user:1 name age city                  <span class=\"token comment\"># \u83b7\u53d6\u591a\u4e2a\u5b57\u6bb5<\/span><br \/>\nHINCRBY user:1 age <span class=\"token number\">1<\/span>                        <span class=\"token comment\"># \u5b57\u6bb5\u503c\u539f\u5b50\u9012\u589e<\/span><br \/>\nHGETALL user:1                              <span class=\"token comment\"># \u83b7\u53d6\u6240\u6709\u5b57\u6bb5\u548c\u503c<\/span><\/p>\n<p>vs String \u5b58 JSON&#xff1a;Hash \u53ef\u4ee5\u5355\u72ec\u83b7\u53d6\/\u4fee\u6539\u67d0\u4e2a\u5b57\u6bb5&#xff0c;\u65e0\u9700\u5e8f\u5217\u5316\/\u53cd\u5e8f\u5217\u5316\u6574\u4e2a\u5bf9\u8c61&#xff0c;\u5185\u5b58\u66f4\u7701&#xff08;\u5c0f\u5bf9\u8c61\u7528 listpack \u7f16\u7801\u65f6\u5c24\u5176\u660e\u663e&#xff09;\u3002<\/p>\n<h5>3.4.3 List&#xff08;\u5217\u8868&#xff09;<\/h5>\n<p>List \u662f\u6709\u5e8f\u7684\u5143\u7d20\u96c6\u5408&#xff0c;\u5e95\u5c42\u7528\u53cc\u5411\u94fe\u8868\u6216 quicklist \u5b9e\u73b0&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u57fa\u672c\u64cd\u4f5c<\/span><br \/>\nLPUSH queue:task <span class=\"token string\">&#034;task1&#034;<\/span> <span class=\"token string\">&#034;task2&#034;<\/span>   <span class=\"token comment\"># \u4ece\u5de6\u4fa7\u538b\u5165<\/span><br \/>\nRPUSH queue:task <span class=\"token string\">&#034;task3&#034;<\/span>           <span class=\"token comment\"># \u4ece\u53f3\u4fa7\u538b\u5165<\/span><br \/>\nLPOP queue:task                    <span class=\"token comment\"># \u4ece\u5de6\u4fa7\u5f39\u51fa \u2192 &#034;task2&#034;<\/span><br \/>\nRPOP queue:task                    <span class=\"token comment\"># \u4ece\u53f3\u4fa7\u5f39\u51fa<\/span><br \/>\nLRANGE queue:task <span class=\"token number\">0<\/span> <span class=\"token parameter variable\">-1<\/span>             <span class=\"token comment\"># \u83b7\u53d6\u6240\u6709\u5143\u7d20<\/span><br \/>\nBLPOP queue:task <span class=\"token number\">30<\/span>                <span class=\"token comment\"># \u963b\u585e\u5f0f\u5f39\u51fa&#xff08;\u8d85\u65f630\u79d2&#xff09;<\/span><\/p>\n<p>\u5178\u578b\u5e94\u7528&#xff1a;\u6d88\u606f\u961f\u5217\u3001\u6700\u65b0\u5217\u8868&#xff08;Timeline&#xff09;\u3001\u6587\u7ae0\u5217\u8868\u3001LRU \u6dd8\u6c70\u8fd1\u4f3c\u5b9e\u73b0<\/p>\n<h5>3.4.4 Set&#xff08;\u96c6\u5408&#xff09;<\/h5>\n<p>Set \u662f\u65e0\u5e8f\u3001\u4e0d\u91cd\u590d\u7684\u5143\u7d20\u96c6\u5408&#xff0c;\u652f\u6301\u4ea4\u5e76\u5dee\u96c6\u8fd0\u7b97&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u57fa\u672c\u64cd\u4f5c<\/span><br \/>\nSADD tags:article:1 <span class=\"token string\">&#034;Redis&#034;<\/span> <span class=\"token string\">&#034;\u7f13\u5b58&#034;<\/span> <span class=\"token string\">&#034;\u6570\u636e\u5e93&#034;<\/span><br \/>\nSADD tags:article:2 <span class=\"token string\">&#034;Redis&#034;<\/span> <span class=\"token string\">&#034;\u9ad8\u53ef\u7528&#034;<\/span> <span class=\"token string\">&#034;\u96c6\u7fa4&#034;<\/span><br \/>\nSMEMBERS tags:article:1                              <span class=\"token comment\"># \u83b7\u53d6\u6240\u6709\u6210\u5458<\/span><br \/>\nSISMEMBER tags:article:1 <span class=\"token string\">&#034;Redis&#034;<\/span>                     <span class=\"token comment\"># \u5224\u65ad\u662f\u5426\u5b58\u5728 \u2192 1<\/span><br \/>\nSINTER tags:article:1 tags:article:2                 <span class=\"token comment\"># \u4ea4\u96c6 \u2192 {&#034;Redis&#034;}<\/span><br \/>\nSUNION tags:article:1 tags:article:2                 <span class=\"token comment\"># \u5e76\u96c6 \u2192 {&#034;Redis&#034;,&#034;\u7f13\u5b58&#034;,&#034;\u6570\u636e\u5e93&#034;,&#034;\u9ad8\u53ef\u7528&#034;,&#034;\u96c6\u7fa4&#034;}<\/span><br \/>\nSDIFF tags:article:1 tags:article:2                  <span class=\"token comment\"># \u5dee\u96c6 \u2192 {&#034;\u7f13\u5b58&#034;,&#034;\u6570\u636e\u5e93&#034;}<\/span><br \/>\nSRANDMEMBER tags:article:1 <span class=\"token number\">2<\/span>                         <span class=\"token comment\"># \u968f\u673a\u83b7\u53d62\u4e2a<\/span><\/p>\n<p>\u5178\u578b\u5e94\u7528&#xff1a;\u6807\u7b7e\u7cfb\u7edf\u3001\u5171\u540c\u597d\u53cb\u3001\u62bd\u5956\u3001\u53bb\u91cd\u3001\u63a8\u8350&#xff08;\u4ea4\u96c6\/\u5e76\u96c6\u8fd0\u7b97&#xff09;<\/p>\n<h5>3.4.5 ZSet&#xff08;\u6709\u5e8f\u96c6\u5408&#xff09;<\/h5>\n<p>ZSet \u5728 Set \u7684\u57fa\u7840\u4e0a\u4e3a\u6bcf\u4e2a\u5143\u7d20\u5173\u8054\u4e00\u4e2a score&#xff0c;\u6309 score \u6392\u5e8f&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u57fa\u672c\u64cd\u4f5c<\/span><br \/>\nZADD leaderboard <span class=\"token number\">100<\/span> <span class=\"token string\">&#034;player1&#034;<\/span> <span class=\"token number\">200<\/span> <span class=\"token string\">&#034;player2&#034;<\/span> <span class=\"token number\">150<\/span> <span class=\"token string\">&#034;player3&#034;<\/span><br \/>\nZINCRBY leaderboard <span class=\"token number\">50<\/span> <span class=\"token string\">&#034;player1&#034;<\/span>                     <span class=\"token comment\"># player1 \u5206\u6570&#043;50 \u2192 150<\/span><br \/>\nZRANGE leaderboard <span class=\"token number\">0<\/span> <span class=\"token parameter variable\">-1<\/span> WITHSCORES                   <span class=\"token comment\"># \u6309\u5206\u6570\u5347\u5e8f<\/span><br \/>\nZREVRANGE leaderboard <span class=\"token number\">0<\/span> <span class=\"token number\">2<\/span> WITHSCORES                 <span class=\"token comment\"># \u6309\u5206\u6570\u964d\u5e8f&#xff0c;\u53d6\u524d3<\/span><br \/>\nZRANGEBYSCORE leaderboard <span class=\"token number\">100<\/span> <span class=\"token number\">200<\/span>                    <span class=\"token comment\"># \u6309\u5206\u6570\u8303\u56f4\u67e5\u8be2<\/span><br \/>\nZRANK leaderboard <span class=\"token string\">&#034;player1&#034;<\/span>                          <span class=\"token comment\"># \u83b7\u53d6\u6392\u540d&#xff08;\u4ece0\u5f00\u59cb&#xff09;<\/span><br \/>\nZCARD leaderboard                                    <span class=\"token comment\"># \u83b7\u53d6\u5143\u7d20\u6570\u91cf<\/span><\/p>\n<p>\u5178\u578b\u5e94\u7528&#xff1a;\u6392\u884c\u699c\u3001\u5ef6\u8fdf\u961f\u5217&#xff08;score \u4e3a\u6267\u884c\u65f6\u95f4&#xff09;\u3001\u5e26\u6743\u91cd\u7684\u4efb\u52a1\u961f\u5217\u3001\u6ed1\u52a8\u7a97\u53e3\u9650\u6d41<\/p>\n<hr \/>\n<h3>\u56db\u3001Redis \u6301\u4e45\u5316\u673a\u5236<\/h3>\n<h4>4.1 RDB \u5feb\u7167&#xff08;Redis Database&#xff09;<\/h4>\n<p>RDB \u662f Redis \u9ed8\u8ba4\u7684\u6301\u4e45\u5316\u65b9\u5f0f&#xff0c;\u5c06\u67d0\u4e00\u65f6\u523b\u7684\u5168\u91cf\u6570\u636e\u4ee5\u4e8c\u8fdb\u5236\u5feb\u7167\u7684\u5f62\u5f0f\u4fdd\u5b58\u5230\u78c1\u76d8&#xff1a;<\/p>\n<p>\u89e6\u53d1\u65b9\u5f0f&#xff1a;<\/p>\n<table>\n<tr>\u89e6\u53d1\u65b9\u5f0f\u914d\u7f6e\/\u547d\u4ee4\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u624b\u52a8\u89e6\u53d1<\/td>\n<td>SAVE \/ BGSAVE<\/td>\n<td>SAVE \u963b\u585e\u4e3b\u7ebf\u7a0b&#xff0c;BGSAVE fork \u5b50\u8fdb\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u914d\u7f6e\u89e6\u53d1<\/td>\n<td>save 900 1<\/td>\n<td>900 \u79d2\u5185\u81f3\u5c11\u6709 1 \u6b21\u5199\u64cd\u4f5c\u5219\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>save 300 10<\/td>\n<td>300 \u79d2\u5185\u81f3\u5c11\u6709 10 \u6b21\u5199\u64cd\u4f5c\u5219\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>save 60 10000<\/td>\n<td>60 \u79d2\u5185\u81f3\u5c11\u6709 10000 \u6b21\u5199\u64cd\u4f5c\u5219\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td>\u81ea\u52a8\u89e6\u53d1<\/td>\n<td>\u4e3b\u4ece\u590d\u5236\u5168\u91cf\u540c\u6b65\u65f6<\/td>\n<td>\u4e3b\u8282\u70b9\u81ea\u52a8\u751f\u6210 RDB \u53d1\u9001\u7ed9\u4ece\u8282\u70b9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>BGSAVE \u5de5\u4f5c\u6d41\u7a0b&#xff1a;<\/p>\n<p>1. Redis \u4e3b\u8fdb\u7a0b fork \u4e00\u4e2a\u5b50\u8fdb\u7a0b<br \/>\n2. \u5b50\u8fdb\u7a0b\u5c06\u5185\u5b58\u6570\u636e\u5199\u5165\u4e34\u65f6 RDB \u6587\u4ef6<br \/>\n3. \u671f\u95f4\u4e3b\u8fdb\u7a0b\u7ee7\u7eed\u5904\u7406\u5ba2\u6237\u7aef\u8bf7\u6c42&#xff08;\u5229\u7528 COW \u673a\u5236&#xff09;<br \/>\n4. \u5b50\u8fdb\u7a0b\u5b8c\u6210\u5199\u5165\u540e&#xff0c;\u7528\u4e34\u65f6\u6587\u4ef6\u66ff\u6362\u65e7 RDB \u6587\u4ef6<br \/>\n5. \u7236\u8fdb\u7a0b\u6536\u5230\u5b50\u8fdb\u7a0b\u5b8c\u6210\u4fe1\u53f7<\/p>\n<p>Copy-On-Write&#xff08;COW&#xff09;\u673a\u5236&#xff1a;fork \u65f6\u7236\u5b50\u8fdb\u7a0b\u5171\u4eab\u540c\u4e00\u7269\u7406\u5185\u5b58\u9875&#xff0c;\u5f53\u4e3b\u8fdb\u7a0b\u4fee\u6539\u67d0\u4e2a\u5185\u5b58\u9875\u65f6&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u590d\u5236\u8be5\u9875\u7ed9\u4e3b\u8fdb\u7a0b&#xff0c;\u5b50\u8fdb\u7a0b\u4ecd\u6301\u6709\u539f\u59cb\u6570\u636e\u3002\u8fd9\u4f7f\u5f97 BGSAVE \u671f\u95f4\u5bf9\u5185\u5b58\u7684\u989d\u5916\u5f00\u9500\u53d6\u51b3\u4e8e\u5199\u64cd\u4f5c\u7684\u591a\u5c11\u3002<\/p>\n<p>\u4f18\u7f3a\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u2705 \u6587\u4ef6\u7d27\u51d1&#xff0c;\u6062\u590d\u901f\u5ea6\u5feb&#xff08;\u76f4\u63a5\u52a0\u8f7d\u5230\u5185\u5b58&#xff09;<\/li>\n<li>\u2705 \u5bf9 Redis \u6027\u80fd\u5f71\u54cd\u5c0f&#xff08;\u5b50\u8fdb\u7a0b\u5904\u7406&#xff0c;\u4e3b\u8fdb\u7a0b\u4e0d\u963b\u585e&#xff09;<\/li>\n<li>\u274c \u53ef\u80fd\u4e22\u5931\u6700\u540e\u4e00\u6b21\u5feb\u7167\u4e4b\u540e\u7684\u6570\u636e<\/li>\n<li>\u274c \u6570\u636e\u91cf\u5927\u65f6 fork \u53ef\u80fd\u963b\u585e&#xff08;fork \u672c\u8eab\u662f\u963b\u585e\u64cd\u4f5c&#xff09;<\/li>\n<\/ul>\n<h4>4.2 AOF&#xff08;Append Only File&#xff09;<\/h4>\n<p>AOF \u4ee5\u65e5\u5fd7\u5f62\u5f0f\u8bb0\u5f55\u6bcf\u4e00\u6761\u5199\u547d\u4ee4&#xff0c;\u901a\u8fc7\u91cd\u653e\u65e5\u5fd7\u6062\u590d\u6570\u636e&#xff1a;<\/p>\n<p>\u4e09\u79cd\u5237\u76d8\u7b56\u7565&#xff1a;<\/p>\n<table>\n<tr>\u7b56\u7565\u914d\u7f6e\u6570\u636e\u5b89\u5168\u6027\u6027\u80fd<\/tr>\n<tbody>\n<tr>\n<td>\u6bcf\u6b21\u5199\u5165\u90fd fsync<\/td>\n<td>always<\/td>\n<td>\u6700\u9ad8&#xff0c;\u51e0\u4e4e\u4e0d\u4e22\u6570\u636e<\/td>\n<td>\u6700\u5dee<\/td>\n<\/tr>\n<tr>\n<td>\u6bcf\u79d2 fsync \u4e00\u6b21<\/td>\n<td>everysec&#xff08;\u9ed8\u8ba4&#xff09;<\/td>\n<td>\u8f83\u9ad8&#xff0c;\u6700\u591a\u4e22 1 \u79d2\u6570\u636e<\/td>\n<td>\u5e73\u8861<\/td>\n<\/tr>\n<tr>\n<td>\u7531\u64cd\u4f5c\u7cfb\u7edf\u51b3\u5b9a<\/td>\n<td>no<\/td>\n<td>\u6700\u4f4e&#xff0c;\u4e22\u5931\u65f6\u957f\u7531 OS \u7b56\u7565\u51b3\u5b9a<\/td>\n<td>\u6700\u597d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>AOF \u91cd\u5199&#xff08;Rewrite&#xff09;&#xff1a;<\/p>\n<p>AOF \u6587\u4ef6\u4f1a\u4e0d\u65ad\u81a8\u80c0&#xff08;\u8bb0\u5f55\u4e86\u5927\u91cf\u5386\u53f2\u5199\u547d\u4ee4&#xff09;&#xff0c;\u9700\u8981\u5b9a\u671f\u91cd\u5199\u538b\u7f29&#xff1a;<\/p>\n<p># \u89e6\u53d1\u6761\u4ef6&#xff08;\u9ed8\u8ba4\u914d\u7f6e&#xff09;<br \/>\nauto-aof-rewrite-min-size 64mb     # AOF \u6587\u4ef6\u81f3\u5c11 64MB \u624d\u89e6\u53d1\u91cd\u5199<br \/>\nauto-aof-rewrite-percentage 100    # AOF \u6587\u4ef6\u6bd4\u4e0a\u6b21\u91cd\u5199\u540e\u589e\u957f\u4e86 100% \u65f6\u89e6\u53d1<\/p>\n<p># \u91cd\u5199\u6d41\u7a0b<br \/>\n1. fork \u5b50\u8fdb\u7a0b<br \/>\n2. \u5b50\u8fdb\u7a0b\u6839\u636e\u5f53\u524d\u5185\u5b58\u6570\u636e\u751f\u6210\u65b0 AOF \u6587\u4ef6&#xff08;\u53ea\u5199\u6700\u7ec8\u72b6\u6001&#xff0c;\u5ffd\u7565\u4e2d\u95f4\u547d\u4ee4&#xff09;<br \/>\n3. \u671f\u95f4\u65b0\u7684\u5199\u547d\u4ee4\u540c\u65f6\u8ffd\u52a0\u5230\u65e7 AOF \u548c\u91cd\u5199\u7f13\u51b2\u533a<br \/>\n4. \u5b50\u8fdb\u7a0b\u5b8c\u6210\u65b0\u6587\u4ef6\u540e&#xff0c;\u5c06\u7f13\u51b2\u533a\u4e2d\u7684\u589e\u91cf\u547d\u4ee4\u8ffd\u52a0\u5230\u65b0\u6587\u4ef6<br \/>\n5. \u539f\u5b50\u66ff\u6362\u65e7 AOF \u6587\u4ef6<\/p>\n<h4>4.3 \u6df7\u5408\u6301\u4e45\u5316&#xff08;Redis 4.0&#043;&#xff09;<\/h4>\n<p>Redis 4.0 \u5f15\u5165\u4e86\u6df7\u5408\u6301\u4e45\u5316\u6a21\u5f0f&#xff0c;\u5c06 RDB \u548c AOF \u7ed3\u5408&#xff1a;<\/p>\n<p># \u5f00\u542f\u6df7\u5408\u6301\u4e45\u5316<br \/>\naof-use-rdb-preamble yes<\/p>\n<p># \u6587\u4ef6\u683c\u5f0f<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502  RDB \u683c\u5f0f\u7684\u5168\u91cf\u6570\u636e \u2502  AOF \u683c\u5f0f\u7684\u589e\u91cf\u547d\u4ee4   \u2502<br \/>\n\u2502  &#xff08;\u6700\u8fd1\u4e00\u6b21\u5feb\u7167&#xff09;   \u2502  &#xff08;\u5feb\u7167\u540e\u7684\u65b0\u5199\u64cd\u4f5c&#xff09;  \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u4f18\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u52a0\u8f7d\u901f\u5ea6\u5feb&#xff08;\u524d\u534a\u90e8\u5206\u662f RDB \u683c\u5f0f&#xff0c;\u76f4\u63a5\u52a0\u8f7d\u5230\u5185\u5b58&#xff09;<\/li>\n<li>\u6570\u636e\u4e22\u5931\u5c11&#xff08;\u540e\u534a\u90e8\u5206 AOF \u8bb0\u5f55\u4e86\u589e\u91cf\u547d\u4ee4&#xff09;<\/li>\n<li>\u517c\u987e\u4e86\u6062\u590d\u901f\u5ea6\u548c\u6570\u636e\u5b8c\u6574\u6027<\/li>\n<\/ul>\n<h4>4.4 \u6301\u4e45\u5316\u9009\u578b\u5efa\u8bae<\/h4>\n<table>\n<tr>\u573a\u666f\u63a8\u8350\u65b9\u6848\u7406\u7531<\/tr>\n<tbody>\n<tr>\n<td>\u7eaf\u7f13\u5b58&#xff0c;\u5141\u8bb8\u4e22\u6570\u636e<\/td>\n<td>\u5173\u95ed\u6301\u4e45\u5316\u6216\u4ec5 RDB<\/td>\n<td>\u6027\u80fd\u6700\u4f18&#xff0c;\u6062\u590d\u5feb<\/td>\n<\/tr>\n<tr>\n<td>\u4e00\u822c\u7f13\u5b58<\/td>\n<td>RDB &#043; AOF&#xff08;everysec&#xff09;<\/td>\n<td>\u6570\u636e\u5b89\u5168\u4e14\u6027\u80fd\u5e73\u8861<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u4e0d\u80fd\u4e22\u5931<\/td>\n<td>AOF&#xff08;always&#xff09;<\/td>\n<td>\u6700\u9ad8\u5b89\u5168\u6027&#xff0c;\u727a\u7272\u6027\u80fd<\/td>\n<\/tr>\n<tr>\n<td>\u751f\u4ea7\u63a8\u8350<\/td>\n<td>\u6df7\u5408\u6301\u4e45\u5316<\/td>\n<td>\u52a0\u8f7d\u5feb &#043; \u6570\u636e\u5b8c\u6574<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e94\u3001Redis \u5185\u5b58\u7ba1\u7406<\/h3>\n<h4>5.1 \u5185\u5b58\u6a21\u578b<\/h4>\n<p>Redis \u7684\u5185\u5b58\u5360\u7528\u7531\u4e94\u4e2a\u90e8\u5206\u7ec4\u6210&#xff1a;<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502            Redis \u8fdb\u7a0b\u603b\u5185\u5b58               \u2502<br \/>\n\u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u2502<br \/>\n\u2502  \u2502 \u6570\u636e\u5185\u5b58    \u2502  \u2502 \u8fdb\u7a0b\u8fd0\u884c\u5185\u5b58        \u2502  \u2502<br \/>\n\u2502  \u2502&#xff08;\u952e\u503c\u5bf9\u6570\u636e&#xff09;\u2502  \u2502&#xff08;\u4ee3\u7801\/\u5e38\u91cf\/\u5806\u6808&#xff09;   \u2502  \u2502<br \/>\n\u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518  \u2502<br \/>\n\u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u2502<br \/>\n\u2502  \u2502         \u7f13\u51b2\u533a\u5185\u5b58                  \u2502  \u2502<br \/>\n\u2502  \u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u2502  \u2502<br \/>\n\u2502  \u2502  \u2502 \u5ba2\u6237\u7aef    \u2502 \u590d\u5236     \u2502 Pub\/Sub\u2502  \u2502  \u2502<br \/>\n\u2502  \u2502  \u2502 \u8f93\u5165\u8f93\u51fa  \u2502 \u79ef\u538b\u7f13\u51b2 \u2502 \u7f13\u51b2\u533a  \u2502  \u2502  \u2502<br \/>\n\u2502  \u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518  \u2502  \u2502<br \/>\n\u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518  \u2502<br \/>\n\u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u2502<br \/>\n\u2502  \u2502 Lua \u811a\u672c\u5185\u5b58&#xff08;\u811a\u672c&#043;\u4e34\u65f6\u6570\u636e&#xff09;       \u2502  \u2502<br \/>\n\u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518  \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<h4>5.2 \u5185\u5b58\u5206\u914d\u5668<\/h4>\n<p>Redis \u4e0d\u76f4\u63a5\u5411\u64cd\u4f5c\u7cfb\u7edf\u7533\u8bf7\/\u91ca\u653e\u5185\u5b58&#xff0c;\u800c\u662f\u901a\u8fc7\u5185\u5b58\u5206\u914d\u5668\u7edf\u4e00\u7ba1\u7406&#xff1a;<\/p>\n<table>\n<tr>\u5206\u914d\u5668\u7279\u70b9<\/tr>\n<tbody>\n<tr>\n<td>jemalloc&#xff08;\u9ed8\u8ba4&#xff09;<\/td>\n<td>\u5185\u5b58\u788e\u7247\u7387\u6781\u4f4e&#xff0c;\u5c06\u5185\u5b58\u5212\u5206\u4e3a\u4e0d\u540c\u5927\u5c0f\u7684\u5757&#xff0c;\u6309\u7533\u8bf7\u5927\u5c0f\u5339\u914d\u6700\u5408\u9002\u7684\u5757<\/td>\n<\/tr>\n<tr>\n<td>tcmalloc<\/td>\n<td>Google \u5f00\u53d1&#xff0c;\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u6027\u80fd\u7565\u4f18<\/td>\n<\/tr>\n<tr>\n<td>libc malloc<\/td>\n<td>\u7cfb\u7edf\u9ed8\u8ba4&#xff0c;\u788e\u7247\u7387\u8f83\u9ad8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u901a\u8fc7 INFO memory \u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u5185\u5b58\u6307\u6807&#xff0c;\u5173\u952e\u6307\u6807&#xff1a;<\/p>\n<ul>\n<li>used_memory&#xff1a;Redis \u5206\u914d\u5668\u5206\u914d\u7684\u5185\u5b58\u603b\u91cf<\/li>\n<li>used_memory_rss&#xff1a;\u64cd\u4f5c\u7cfb\u7edf\u5206\u914d\u7ed9 Redis \u7684\u7269\u7406\u5185\u5b58<\/li>\n<li>mem_fragmentation_ratio&#xff1a;rss \/ used_memory&#xff0c;\u788e\u7247\u7387\u6307\u6807&#xff0c;\u4e00\u822c 1.0-1.5 \u4e3a\u6b63\u5e38<\/li>\n<\/ul>\n<h4>5.3 \u8fc7\u671f\u5220\u9664\u7b56\u7565<\/h4>\n<p>Redis \u91c7\u7528 \u60f0\u6027\u5220\u9664 &#043; \u5b9a\u671f\u5220\u9664 \u7ec4\u5408\u7b56\u7565\u6e05\u7406\u8fc7\u671f key&#xff1a;<\/p>\n<p>\u60f0\u6027\u5220\u9664&#xff1a;<\/p>\n<ul>\n<li>\u6bcf\u6b21\u5ba2\u6237\u7aef\u8bbf\u95ee\u67d0\u4e2a key \u65f6&#xff0c;Redis \u5148\u68c0\u67e5\u8be5 key \u662f\u5426\u5df2\u8fc7\u671f<\/li>\n<li>\u5df2\u8fc7\u671f\u5219\u7acb\u5373\u5220\u9664\u5e76\u8fd4\u56de\u7a7a\u503c<\/li>\n<li>\u4f18\u70b9&#xff1a;CPU \u96f6\u989d\u5916\u5f00\u9500<\/li>\n<li>\u7f3a\u70b9&#xff1a;\u8fc7\u671f key \u82e5\u957f\u671f\u4e0d\u88ab\u8bbf\u95ee&#xff0c;\u4f1a\u6c38\u4e45\u5360\u7528\u5185\u5b58<\/li>\n<\/ul>\n<p>\u5b9a\u671f\u5220\u9664&#xff1a;<\/p>\n<ul>\n<li>\u5b9a\u65f6\u4efb\u52a1 serverCron&#xff08;\u9ed8\u8ba4\u6bcf 100ms \u6267\u884c\u4e00\u6b21&#xff09;\u8c03\u7528 activeExpireCycle \u51fd\u6570<\/li>\n<li>\u904d\u5386\u8fc7\u671f\u952e\u54c8\u5e0c\u69fd\u62bd\u6837\u68c0\u67e5&#xff0c;\u5355\u4e2a\u69fd\u4f4d\u4e00\u8f6e\u6700\u591a 20 \u6b21\u91c7\u6837<\/li>\n<li>\u62bd\u6837\u68c0\u6d4b\u5230\u8fc7\u671f key \u7acb\u5373\u5220\u9664&#xff1b;\u6837\u672c\u8fc7\u671f\u5360\u6bd4\u226525% \u5219\u6301\u7eed\u5faa\u73af\u62bd\u6837<\/li>\n<li>\u5b58\u5728\u6267\u884c\u65f6\u957f\u4e0a\u9650&#xff0c;\u9ed8\u8ba4\u6700\u591a\u8fd0\u884c 25ms&#xff0c;\u907f\u514d\u963b\u585e\u4e3b\u7ebf\u7a0b<\/li>\n<li>\u4f18\u70b9&#xff1a;\u4e3b\u52a8\u6e05\u7406\u51b7\u6570\u636e&#xff0c;\u5e73\u8861 CPU \u4e0e\u5185\u5b58<\/li>\n<\/ul>\n<h4>5.4 \u5185\u5b58\u6dd8\u6c70\u7b56\u7565<\/h4>\n<p>\u5f53\u5df2\u4f7f\u7528\u5185\u5b58\u8fbe\u5230 maxmemory \u9608\u503c\u65f6&#xff0c;Redis \u6839\u636e maxmemory-policy \u914d\u7f6e\u6267\u884c\u6dd8\u6c70&#xff1a;<\/p>\n<table>\n<tr>\u7b56\u7565\u6dd8\u6c70\u8303\u56f4\u6dd8\u6c70\u89c4\u5219\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>noeviction<\/td>\n<td>\u4e0d\u6dd8\u6c70<\/td>\n<td>\u5199\u64cd\u4f5c\u8fd4\u56de OOM \u9519\u8bef<\/td>\n<td>\u6838\u5fc3\u6570\u636e\u4e0d\u53ef\u4e22\u5931<\/td>\n<\/tr>\n<tr>\n<td>allkeys-lru<\/td>\n<td>\u6240\u6709 key<\/td>\n<td>\u6dd8\u6c70\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\u7684 key<\/td>\n<td>\u7eaf\u7f13\u5b58\u573a\u666f\u9996\u9009<\/td>\n<\/tr>\n<tr>\n<td>allkeys-lfu<\/td>\n<td>\u6240\u6709 key<\/td>\n<td>\u6dd8\u6c70\u8bbf\u95ee\u9891\u6b21\u6700\u4f4e\u7684 key&#xff08;Redis 4.0&#043;&#xff09;<\/td>\n<td>\u7eaf\u7f13\u5b58&#xff0c;\u6709\u660e\u786e\u70ed\u70b9<\/td>\n<\/tr>\n<tr>\n<td>allkeys-random<\/td>\n<td>\u6240\u6709 key<\/td>\n<td>\u968f\u673a\u6dd8\u6c70<\/td>\n<td>\u6781\u5c11\u4f7f\u7528<\/td>\n<\/tr>\n<tr>\n<td>volatile-lru<\/td>\n<td>\u4ec5\u8fc7\u671f key<\/td>\n<td>\u6dd8\u6c70\u8fc7\u671f key \u4e2d\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\u7684<\/td>\n<td>\u6df7\u5408\u5b58\u50a8&#xff08;\u6c38\u4e45&#043;\u4e34\u65f6&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>volatile-lfu<\/td>\n<td>\u4ec5\u8fc7\u671f key<\/td>\n<td>\u6dd8\u6c70\u8fc7\u671f key \u4e2d\u8bbf\u95ee\u9891\u6b21\u6700\u4f4e\u7684<\/td>\n<td>\u6df7\u5408\u5b58\u50a8<\/td>\n<\/tr>\n<tr>\n<td>volatile-random<\/td>\n<td>\u4ec5\u8fc7\u671f key<\/td>\n<td>\u968f\u673a\u6dd8\u6c70\u8fc7\u671f key<\/td>\n<td>\u8fc7\u671f key \u65e0\u660e\u663e\u70ed\u70b9<\/td>\n<\/tr>\n<tr>\n<td>volatile-ttl<\/td>\n<td>\u4ec5\u8fc7\u671f key<\/td>\n<td>\u6dd8\u6c70\u5269\u4f59 TTL \u6700\u77ed\u7684 key<\/td>\n<td>\u77ed\u671f\u4e34\u65f6\u7f13\u5b58<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>LRU vs LFU&#xff1a;<\/p>\n<ul>\n<li>LRU&#xff08;\u6700\u8fd1\u6700\u5c11\u4f7f\u7528&#xff09;&#xff1a;\u57fa\u4e8e\u65f6\u95f4\u7ef4\u5ea6&#xff0c;\u6dd8\u6c70\u6700\u4e45\u672a\u8bbf\u95ee\u7684 key\u3002\u7f3a\u70b9&#xff1a;\u66fe\u7ecf\u7684\u70ed\u70b9 key \u957f\u671f\u4e0d\u8bbf\u95ee\u540e\u4ecd\u5360\u5185\u5b58&#xff08;\u7f13\u5b58\u6c61\u67d3&#xff09;<\/li>\n<li>LFU&#xff08;\u6700\u4e0d\u7ecf\u5e38\u4f7f\u7528&#xff09;&#xff1a;\u57fa\u4e8e\u9891\u6b21\u7ef4\u5ea6&#xff0c;\u5229\u7528 redisObject \u7684 24 \u4f4d lru \u5b57\u6bb5&#xff08;\u9ad8 16 \u4f4d\u8bb0\u5f55\u65f6\u95f4&#xff0c;\u4f4e 8 \u4f4d\u7528 Morris \u6982\u7387\u8ba1\u6570\u5668\u8bb0\u5f55\u9891\u6b21&#xff09;&#xff0c;\u914d\u5408\u65f6\u95f4\u8870\u51cf\u673a\u5236&#xff08;lfu-decay-time&#xff09;<\/li>\n<\/ul>\n<p>\u751f\u4ea7\u9009\u578b\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\u7eaf\u7f13\u5b58 \u2192 allkeys-lfu \u6216 allkeys-lru<\/li>\n<li>\u6df7\u5408\u5b58\u50a8 \u2192 volatile-lru \u6216 volatile-lfu<\/li>\n<li>\u6838\u5fc3\u6570\u636e\u4e0d\u4e22 \u2192 noeviction&#xff08;\u914d\u5408\u624b\u52a8\u6269\u5bb9&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3>\u516d\u3001Redis \u4e8b\u52a1\u4e0e\u9ad8\u7ea7\u7279\u6027<\/h3>\n<h4>6.1 \u4e8b\u52a1\u673a\u5236<\/h4>\n<p>Redis \u4e8b\u52a1\u901a\u8fc7 MULTI\/EXEC \u5b9e\u73b0&#xff1a;<\/p>\n<p>MULTI                    <span class=\"token comment\"># \u5f00\u542f\u4e8b\u52a1<\/span><br \/>\nSET account:1:balance <span class=\"token number\">100<\/span><br \/>\nINCRBY account:1:balance <span class=\"token parameter variable\">-50<\/span><br \/>\nSET account:2:balance <span class=\"token number\">50<\/span><br \/>\nINCRBY account:2:balance <span class=\"token number\">50<\/span><br \/>\nEXEC                     <span class=\"token comment\"># \u6267\u884c\u4e8b\u52a1&#xff08;\u6309\u987a\u5e8f\u539f\u5b50\u6267\u884c&#xff09;<\/span><\/p>\n<p>\u7279\u6027&#xff1a;<\/p>\n<ul>\n<li>\u547d\u4ee4\u5165\u961f\u65f6\u4e0d\u505a\u6267\u884c&#xff0c;\u53ea\u8fd4\u56de QUEUED<\/li>\n<li>EXEC \u65f6\u6309\u987a\u5e8f\u4f9d\u6b21\u6267\u884c\u6240\u6709\u547d\u4ee4<\/li>\n<li>\u4e0d\u652f\u6301\u56de\u6eda\u2014\u2014\u5982\u679c\u67d0\u6761\u547d\u4ee4\u6267\u884c\u51fa\u9519&#xff0c;\u540e\u7eed\u547d\u4ee4\u4ecd\u7136\u6267\u884c<\/li>\n<li>\u901a\u8fc7 WATCH \u5b9e\u73b0\u4e50\u89c2\u9501&#xff1a;<\/li>\n<\/ul>\n<p>WATCH account:1:balance      <span class=\"token comment\"># \u76d1\u89c6 key<\/span><br \/>\nMULTI<br \/>\n<span class=\"token comment\"># &#8230; \u68c0\u67e5\u4f59\u989d\u5e76\u6263\u6b3e<\/span><br \/>\nEXEC                         <span class=\"token comment\"># \u5982\u679c WATCH \u7684 key \u88ab\u5176\u4ed6\u5ba2\u6237\u7aef\u4fee\u6539&#xff0c;EXEC \u8fd4\u56de nil<\/span><\/p>\n<h4>6.2 Pipeline&#xff08;\u7ba1\u9053&#xff09;<\/h4>\n<p>Pipeline \u5c06\u591a\u4e2a\u547d\u4ee4\u6253\u5305\u4e00\u6b21\u6027\u53d1\u9001\u5230\u670d\u52a1\u7aef&#xff0c;\u51cf\u5c11\u7f51\u7edc RTT&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u4e0d\u7528 Pipeline&#xff08;4\u6b21\u7f51\u7edc\u5f80\u8fd4&#xff09;<\/span><br \/>\nSET key1 value1<br \/>\nSET key2 value2<br \/>\nSET key3 value3<br \/>\nGET key1<\/p>\n<p><span class=\"token comment\"># \u4f7f\u7528 Pipeline&#xff08;1\u6b21\u7f51\u7edc\u5f80\u8fd4&#xff09;<\/span><br \/>\nPipeline:<br \/>\n  SET key1 value1<br \/>\n  SET key2 value2<br \/>\n  SET key3 value3<br \/>\n  GET key1<\/p>\n<p>\u6027\u80fd\u5dee\u5f02&#xff1a;\u5355\u6761\u547d\u4ee4 0.1ms RTT&#xff0c;1000 \u6761\u547d\u4ee4\u4e0d\u7528 Pipeline \u9700\u8981 100ms&#xff0c;\u4f7f\u7528 Pipeline \u7ea6 10ms\u3002<\/p>\n<h4>6.3 Lua \u811a\u672c<\/h4>\n<p>Redis \u652f\u6301\u6267\u884c Lua \u811a\u672c&#xff0c;\u4fdd\u8bc1\u811a\u672c\u5185\u547d\u4ee4\u7684\u539f\u5b50\u6027&#xff1a;<\/p>\n<p>EVAL <span class=\"token string\">&#034;<br \/>\nlocal current &#061; redis.call(&#039;GET&#039;, KEYS[1])<br \/>\nif current &#061;&#061; false then<br \/>\n    redis.call(&#039;SET&#039;, KEYS[1], ARGV[1])<br \/>\n    return 1<br \/>\nend<br \/>\nreturn 0<br \/>\n&#034;<\/span> <span class=\"token number\">1<\/span> mykey myvalue<\/p>\n<p>Lua \u811a\u672c\u7684\u539f\u5b50\u6027\u4fdd\u8bc1&#xff1a;\u6574\u4e2a\u811a\u672c\u4f5c\u4e3a\u4e00\u4e2a\u547d\u4ee4\u6267\u884c&#xff0c;\u6267\u884c\u671f\u95f4\u4e0d\u4f1a\u88ab\u5176\u4ed6\u547d\u4ee4\u63d2\u5165\u3002\u9002\u5408\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u3001\u9650\u6d41\u5668\u7b49\u9700\u8981\u539f\u5b50\u6027\u7684\u590d\u6742\u64cd\u4f5c\u3002<\/p>\n<h4>6.4 Pub\/Sub \u53d1\u5e03\u8ba2\u9605<\/h4>\n<p><span class=\"token comment\"># \u8ba2\u9605\u9891\u9053<\/span><br \/>\nSUBSCRIBE news:sports news:tech<\/p>\n<p><span class=\"token comment\"># \u53d1\u5e03\u6d88\u606f<\/span><br \/>\nPUBLISH news:sports <span class=\"token string\">&#034;\u56fd\u8db32:1\u80dc\u51fa&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u6a21\u5f0f\u8ba2\u9605&#xff08;\u652f\u6301\u901a\u914d\u7b26&#xff09;<\/span><br \/>\nPSUBSCRIBE news:*<\/p>\n<p>Stream&#xff08;Redis 5.0&#043;&#xff09; \u662f\u5bf9 Pub\/Sub \u7684\u5347\u7ea7&#xff0c;\u652f\u6301\u6d88\u606f\u6301\u4e45\u5316\u3001\u6d88\u8d39\u8005\u7ec4\u548c ACK&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u6d88\u606f<\/span><br \/>\nXADD mystream * sensor_id <span class=\"token number\">1234<\/span> temperature <span class=\"token number\">19.8<\/span><\/p>\n<p><span class=\"token comment\"># \u6d88\u8d39\u8005\u7ec4<\/span><br \/>\nXGROUP CREATE mystream mygroup $ MKSTREAM<br \/>\nXREADGROUP GROUP mygroup consumer1 COUNT <span class=\"token number\">10<\/span> BLOCK <span class=\"token number\">5000<\/span> STREAMS mystream <span class=\"token operator\">&gt;<\/span><br \/>\nXACK mystream mygroup <span class=\"token number\">1526985685<\/span>-0<\/p>\n<hr \/>\n<h3>\u4e03\u3001Redis \u9ad8\u53ef\u7528\u67b6\u6784<\/h3>\n<h4>7.1 \u4e3b\u4ece\u590d\u5236<\/h4>\n<p>\u6838\u5fc3\u539f\u7406&#xff1a;<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510    \u5168\u91cf\u540c\u6b65&#xff08;\u9996\u6b21&#xff09;    \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502  Master   \u2502 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt; \u2502  Slave1   \u2502<br \/>\n\u2502  (\u4e3b\u8282\u70b9)  \u2502    \u589e\u91cf\u540c\u6b65&#xff08;\u540e\u7eed&#xff09;    \u2502  (\u4ece\u8282\u70b9)  \u2502<br \/>\n\u2502           \u2502 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt; \u2502           \u2502<br \/>\n\u2502           \u2502                      \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n\u2502           \u2502    \u5168\u91cf\/\u589e\u91cf\u540c\u6b65      \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502           \u2502 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt; \u2502  Slave2   \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                      \u2502  (\u4ece\u8282\u70b9)  \u2502<br \/>\n                                  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u5168\u91cf\u540c\u6b65&#xff08;\u9996\u6b21\u8fde\u63a5\u6216\u65ad\u8fde\u8fc7\u4e45&#xff09;&#xff1a;<\/p>\n<li>Slave \u53d1\u9001 PSYNC ? -1<\/li>\n<li>Master \u6267\u884c BGSAVE \u751f\u6210 RDB \u5feb\u7167<\/li>\n<li>Master \u5c06 RDB \u53d1\u9001\u7ed9 Slave<\/li>\n<li>Slave \u52a0\u8f7d RDB \u5230\u5185\u5b58<\/li>\n<li>Master \u5c06\u671f\u95f4\u7684\u589e\u91cf\u547d\u4ee4\u53d1\u9001\u7ed9 Slave \u6267\u884c<\/li>\n<p>\u589e\u91cf\u540c\u6b65&#xff08;\u6b63\u5e38\u60c5\u51b5&#xff09;&#xff1a;<\/p>\n<li>Master \u7ef4\u62a4\u4e00\u4e2a replication backlog&#xff08;\u590d\u5236\u79ef\u538b\u7f13\u51b2\u533a&#xff0c;\u9ed8\u8ba4 1MB&#xff09;<\/li>\n<li>Slave \u53d1\u9001 PSYNC &lt;runid&gt; &lt;offset&gt;<\/li>\n<li>Master \u6839\u636e offset \u4ece backlog \u4e2d\u53d1\u9001\u589e\u91cf\u6570\u636e<\/li>\n<h4>7.2 \u54e8\u5175\u6a21\u5f0f&#xff08;Sentinel&#xff09;<\/h4>\n<p>\u54e8\u5175\u662f\u4e3b\u4ece\u590d\u5236\u7684\u5347\u7ea7\u65b9\u6848&#xff0c;\u63d0\u4f9b\u81ea\u52a8\u6545\u969c\u8f6c\u79fb&#xff1a;<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;<\/p>\n<ul>\n<li>\u76d1\u63a7&#xff1a;\u6301\u7eed\u68c0\u6d4b Master \u548c Slave \u662f\u5426\u6b63\u5e38\u8fd0\u884c<\/li>\n<li>\u901a\u77e5&#xff1a;\u5f53\u88ab\u76d1\u63a7\u7684\u5b9e\u4f8b\u51fa\u73b0\u95ee\u9898\u65f6&#xff0c;\u901a\u8fc7 Pub\/Sub \u901a\u77e5\u7ba1\u7406\u5458<\/li>\n<li>\u81ea\u52a8\u6545\u969c\u8f6c\u79fb&#xff1a;Master \u4e0d\u53ef\u7528\u65f6&#xff0c;\u81ea\u52a8\u5c06\u67d0\u4e2a Slave \u63d0\u5347\u4e3a\u65b0\u7684 Master<\/li>\n<li>\u914d\u7f6e\u4e2d\u5fc3&#xff1a;\u5ba2\u6237\u7aef\u8fde\u63a5 Sentinel \u83b7\u53d6\u5f53\u524d Master \u5730\u5740&#xff0c;\u6545\u969c\u8f6c\u79fb\u540e\u81ea\u52a8\u66f4\u65b0<\/li>\n<\/ul>\n<p>\u6545\u969c\u5224\u5b9a\u6d41\u7a0b&#xff1a;<\/p>\n<li>Sentinel \u6bcf\u79d2\u5411\u6240\u6709\u5b9e\u4f8b\u53d1\u9001 PING<\/li>\n<li>\u8d85\u8fc7 down-after-milliseconds \u672a\u54cd\u5e94 \u2192 \u6807\u8bb0\u4e3a\u4e3b\u89c2\u4e0b\u7ebf&#xff08;SDOWN&#xff09;<\/li>\n<li>\u591a\u4e2a Sentinel \u90fd\u8ba4\u4e3a Master \u4e3b\u89c2\u4e0b\u7ebf \u2192 \u6807\u8bb0\u4e3a\u5ba2\u89c2\u4e0b\u7ebf&#xff08;ODOWN&#xff09;<\/li>\n<li>Sentinel \u9009\u4e3e\u4e00\u4e2a Leader \u6267\u884c\u6545\u969c\u8f6c\u79fb<\/li>\n<li>Leader \u9009\u62e9\u4e00\u4e2a Slave \u63d0\u5347\u4e3a\u65b0 Master&#xff08;\u4f18\u5148\u7ea7&#xff1a;replica-priority \u6700\u9ad8\u3001\u590d\u5236\u504f\u79fb\u91cf\u6700\u5927\u3001runid \u6700\u5c0f&#xff09;<\/li>\n<li>\u5176\u4ed6 Slave \u6539\u4e3a\u590d\u5236\u65b0 Master<\/li>\n<li>\u901a\u77e5\u5ba2\u6237\u7aef\u65b0 Master \u5730\u5740<\/li>\n<p><span class=\"token comment\"># Sentinel \u914d\u7f6e\u793a\u4f8b<\/span><br \/>\nsentinel monitor mymaster <span class=\"token number\">127.0<\/span>.0.1 <span class=\"token number\">6379<\/span> <span class=\"token number\">2<\/span>     <span class=\"token comment\"># \u76d1\u63a7\u4e3b\u8282\u70b9&#xff0c;2\u4e2asentinel\u540c\u610f\u5373\u6545\u969c\u8f6c\u79fb<\/span><br \/>\nsentinel down-after-milliseconds mymaster <span class=\"token number\">5000<\/span>  <span class=\"token comment\"># 5\u79d2\u65e0\u54cd\u5e94\u89c6\u4e3a\u4e0b\u7ebf<\/span><br \/>\nsentinel parallel-syncs mymaster <span class=\"token number\">1<\/span>              <span class=\"token comment\"># \u6545\u969c\u8f6c\u79fb\u540e\u4e00\u6b21\u53ea\u540c\u6b65\u4e00\u4e2a\u4ece\u8282\u70b9<\/span><br \/>\nsentinel failover-timeout mymaster <span class=\"token number\">60000<\/span>        <span class=\"token comment\"># \u6545\u969c\u8f6c\u79fb\u8d85\u65f6\u65f6\u95f4<\/span><\/p>\n<h4>7.3 Redis Cluster&#xff08;\u96c6\u7fa4&#xff09;<\/h4>\n<p>Redis Cluster \u662f Redis \u5b98\u65b9\u7684\u5206\u5e03\u5f0f\u65b9\u6848&#xff08;Redis 3.0&#043;&#xff09;&#xff0c;\u63d0\u4f9b\u6570\u636e\u5206\u7247\u3001\u9ad8\u53ef\u7528\u548c\u6c34\u5e73\u6269\u5c55&#xff1a;<\/p>\n<p>\u6838\u5fc3\u8bbe\u8ba1&#xff1a;<\/p>\n<ul>\n<li>\u6570\u636e\u5206\u7247&#xff1a;\u4f7f\u7528\u54c8\u5e0c\u69fd&#xff08;Hash Slot&#xff09;\u673a\u5236&#xff0c;\u5171 16384 \u4e2a\u69fd<\/li>\n<li>\u69fd\u5206\u914d&#xff1a;CRC16(key) % 16384 \u51b3\u5b9a key \u5c5e\u4e8e\u54ea\u4e2a\u69fd<\/li>\n<li>\u8282\u70b9\u5206\u914d&#xff1a;\u6bcf\u4e2a Master \u8d1f\u8d23\u4e00\u90e8\u5206\u69fd&#xff0c;Slave \u4f5c\u4e3a\u5bf9\u5e94 Master \u7684\u5907\u4efd<\/li>\n<\/ul>\n<p>\u67b6\u6784\u793a\u4f8b&#xff08;3 \u4e3b 3 \u4ece&#xff09;&#xff1a;<\/p>\n<p>Master A: slot 0-5460      \u2190\u2192    Slave A&#039;: \u5907\u4efd Master A<br \/>\nMaster B: slot 5461-10922  \u2190\u2192    Slave B&#039;: \u5907\u4efd Master B<br \/>\nMaster C: slot 10923-16383 \u2190\u2192    Slave C&#039;: \u5907\u4efd Master C<\/p>\n<p>\u5173\u952e\u7279\u6027&#xff1a;<\/p>\n<table>\n<tr>\u7279\u6027\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u53bb\u4e2d\u5fc3\u5316<\/td>\n<td>\u6240\u6709\u8282\u70b9\u901a\u8fc7 Gossip \u534f\u8bae\u901a\u4fe1&#xff0c;\u65e0\u4e2d\u5fc3\u4ee3\u7406<\/td>\n<\/tr>\n<tr>\n<td>\u5ba2\u6237\u7aef\u91cd\u5b9a\u5411<\/td>\n<td>\u8bbf\u95ee\u9519\u8bef\u7684\u8282\u70b9\u65f6\u8fd4\u56de MOVED \u91cd\u5b9a\u5411\u5230\u6b63\u786e\u7684\u8282\u70b9<\/td>\n<\/tr>\n<tr>\n<td>\u5728\u7ebf\u6269\u7f29\u5bb9<\/td>\n<td>\u901a\u8fc7\u8fc1\u79fb\u69fd\u5b9e\u73b0\u8282\u70b9\u7684\u6dfb\u52a0\u548c\u79fb\u9664&#xff0c;\u670d\u52a1\u4e0d\u4e2d\u65ad<\/td>\n<\/tr>\n<tr>\n<td>\u6545\u969c\u8f6c\u79fb<\/td>\n<td>\u96c6\u7fa4\u4e2d\u591a\u6570 Master \u8ba4\u4e3a\u67d0 Master \u4e0d\u53ef\u8fbe\u65f6&#xff0c;\u81ea\u52a8\u63d0\u5347\u5176 Slave<\/td>\n<\/tr>\n<tr>\n<td>\u5f02\u6b65\u590d\u5236<\/td>\n<td>\u4e3b\u4ece\u4e4b\u95f4\u5f02\u6b65\u590d\u5236&#xff0c;\u6781\u7aef\u60c5\u51b5\u4e0b\u53ef\u80fd\u4e22\u6570\u636e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>MOVED \u4e0e ASK&#xff1a;<\/p>\n<ul>\n<li>MOVED slot ip:port&#xff1a;\u69fd\u5df2\u6c38\u4e45\u8fc1\u79fb&#xff0c;\u5ba2\u6237\u7aef\u66f4\u65b0\u672c\u5730\u8def\u7531\u8868<\/li>\n<li>ASK slot ip:port&#xff1a;\u69fd\u6b63\u5728\u8fc1\u79fb\u4e2d&#xff08;\u4e34\u65f6\u72b6\u6001&#xff09;&#xff0c;\u5ba2\u6237\u7aef\u672c\u6b21\u91cd\u5b9a\u5411&#xff0c;\u4e0d\u66f4\u65b0\u8def\u7531\u8868<\/li>\n<\/ul>\n<p>Hash Tag&#xff1a;\u901a\u8fc7 {} \u5f3a\u5236\u76f8\u5173 key \u843d\u5728\u540c\u4e00\u69fd&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u4ee5\u4e0b\u4e24\u4e2a key \u4f1a\u843d\u5728\u540c\u4e00\u4e2a\u69fd&#xff08;\u56e0\u4e3a hash tag \u90fd\u662f user:1&#xff09;<\/span><br \/>\nSET <span class=\"token punctuation\">{<\/span>user:1<span class=\"token punctuation\">}<\/span>:name <span class=\"token string\">&#034;\u5f20\u4e09&#034;<\/span><br \/>\nSET <span class=\"token punctuation\">{<\/span>user:1<span class=\"token punctuation\">}<\/span>:age <span class=\"token number\">28<\/span><\/p>\n<hr \/>\n<h3>\u516b\u3001Redis \u751f\u4ea7\u5b9e\u8df5<\/h3>\n<h4>8.1 \u7f13\u5b58\u4e09\u5927\u95ee\u9898<\/h4>\n<table>\n<tr>\u95ee\u9898\u63cf\u8ff0\u89e3\u51b3\u65b9\u6848<\/tr>\n<tbody>\n<tr>\n<td>\u7f13\u5b58\u7a7f\u900f<\/td>\n<td>\u67e5\u8be2\u4e0d\u5b58\u5728\u7684\u6570\u636e&#xff0c;\u6bcf\u6b21\u90fd\u7a7f\u900f\u5230 DB<\/td>\n<td>\u5e03\u9686\u8fc7\u6ee4\u5668&#xff1b;\u7a7a\u503c\u7f13\u5b58&#xff08;\u8bbe\u77ed TTL&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7f13\u5b58\u51fb\u7a7f<\/td>\n<td>\u70ed\u70b9 key \u8fc7\u671f\u77ac\u95f4&#xff0c;\u5927\u91cf\u8bf7\u6c42\u6253\u5230 DB<\/td>\n<td>\u4e92\u65a5\u9501&#xff08;SETNX&#xff09;&#xff1b;\u70ed\u70b9 key \u6c38\u4e0d\u8fc7\u671f&#xff1b;\u903b\u8f91\u8fc7\u671f<\/td>\n<\/tr>\n<tr>\n<td>\u7f13\u5b58\u96ea\u5d29<\/td>\n<td>\u5927\u91cf key \u540c\u65f6\u8fc7\u671f\u6216 Redis \u5b95\u673a<\/td>\n<td>TTL \u52a0\u968f\u673a\u503c&#xff1b;\u591a\u7ea7\u7f13\u5b58&#xff1b;\u96c6\u7fa4\u9ad8\u53ef\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>8.2 \u5206\u5e03\u5f0f\u9501\u5b9e\u73b0<\/h4>\n<p><span class=\"token comment\"># \u52a0\u9501&#xff08;\u539f\u5b50\u64cd\u4f5c&#xff09;<\/span><br \/>\nSET lock:order:123 uuid NX PX <span class=\"token number\">30000<\/span><\/p>\n<p><span class=\"token comment\"># \u89e3\u9501&#xff08;Lua \u811a\u672c\u4fdd\u8bc1\u539f\u5b50\u6027&#xff09;<\/span><br \/>\nEVAL <span class=\"token string\">&#034;<br \/>\nif redis.call(&#039;GET&#039;, KEYS[1]) &#061;&#061; ARGV[1] then<br \/>\n    return redis.call(&#039;DEL&#039;, KEYS[1])<br \/>\nelse<br \/>\n    return 0<br \/>\nend<br \/>\n&#034;<\/span> <span class=\"token number\">1<\/span> lock:order:123 uuid<\/p>\n<p>\u751f\u4ea7\u5efa\u8bae&#xff1a;\u5355\u673a\u9501\u7528 Redis \u5373\u53ef&#xff1b;\u591a\u8282\u70b9\u5f3a\u4e00\u81f4\u6027\u573a\u666f\u63a8\u8350\u4f7f\u7528 RedLock \u6216 ZooKeeper\u3002<\/p>\n<h4>8.3 Redis \u4e0e\u5176\u4ed6\u7ec4\u4ef6\u7684\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u7ef4\u5ea6RedisMemcachedMongoDB<\/tr>\n<tbody>\n<tr>\n<td>\u6570\u636e\u7ed3\u6784<\/td>\n<td>\u4e30\u5bcc&#xff08;String\/Hash\/List\/Set\/ZSet\/Stream&#xff09;<\/td>\n<td>\u7b80\u5355 KV<\/td>\n<td>\u6587\u6863\u578b&#xff08;BSON&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6301\u4e45\u5316<\/td>\n<td>RDB &#043; AOF<\/td>\n<td>\u4e0d\u652f\u6301<\/td>\n<td>\u539f\u751f\u652f\u6301<\/td>\n<\/tr>\n<tr>\n<td>\u7ebf\u7a0b\u6a21\u578b<\/td>\n<td>\u5355\u7ebf\u7a0b\u6267\u884c&#xff08;6.0&#043; \u591a\u7ebf\u7a0bIO&#xff09;<\/td>\n<td>\u591a\u7ebf\u7a0b<\/td>\n<td>\u591a\u7ebf\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u96c6\u7fa4<\/td>\n<td>Cluster&#xff08;\u539f\u751f\u5206\u7247&#xff09;<\/td>\n<td>\u5ba2\u6237\u7aef\u5206\u7247<\/td>\n<td>\u539f\u751f\u5206\u7247<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u7ba1\u7406<\/td>\n<td>\u7cbe\u7ec6&#xff08;jemalloc &#043; \u591a\u79cd\u6dd8\u6c70\u7b56\u7565&#xff09;<\/td>\n<td>\u7b80\u5355 slab \u5206\u914d<\/td>\n<td>WiredTiger \u5f15\u64ce<\/td>\n<\/tr>\n<tr>\n<td>\u4e8b\u52a1<\/td>\n<td>MULTI\/EXEC&#xff08;\u4e0d\u652f\u6301\u56de\u6eda&#xff09;<\/td>\n<td>\u4e0d\u652f\u6301<\/td>\n<td>\u591a\u6587\u6863\u4e8b\u52a1&#xff08;4.0&#043;&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u7f13\u5b58\/\u961f\u5217\/\u6392\u884c\u699c\/\u5206\u5e03\u5f0f\u9501<\/td>\n<td>\u7b80\u5355\u7f13\u5b58<\/td>\n<td>\u6587\u6863\u5b58\u50a8\/\u5185\u5bb9\u7ba1\u7406<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>8.4 \u5173\u952e\u914d\u7f6e\u8c03\u4f18<\/h4>\n<p><span class=\"token comment\"># \u5185\u5b58\u914d\u7f6e<\/span><br \/>\nmaxmemory 8gb                    <span class=\"token comment\"># \u6700\u5927\u5185\u5b58&#xff08;\u5efa\u8bae\u9884\u7559 30% \u7ed9\u7cfb\u7edf&#xff09;<\/span><br \/>\nmaxmemory-policy allkeys-lfu     <span class=\"token comment\"># \u6dd8\u6c70\u7b56\u7565<\/span><\/p>\n<p><span class=\"token comment\"># \u6301\u4e45\u5316\u914d\u7f6e<\/span><br \/>\nsave <span class=\"token number\">900<\/span> <span class=\"token number\">1<\/span>                       <span class=\"token comment\"># RDB \u89e6\u53d1\u6761\u4ef6<\/span><br \/>\nsave <span class=\"token number\">300<\/span> <span class=\"token number\">10<\/span><br \/>\nsave <span class=\"token number\">60<\/span> <span class=\"token number\">10000<\/span><br \/>\naof-use-rdb-preamble <span class=\"token function\">yes<\/span>         <span class=\"token comment\"># \u6df7\u5408\u6301\u4e45\u5316<\/span><br \/>\nauto-aof-rewrite-percentage <span class=\"token number\">100<\/span>  <span class=\"token comment\"># AOF \u91cd\u5199\u89e6\u53d1<\/span><\/p>\n<p><span class=\"token comment\"># \u7f51\u7edc\u914d\u7f6e<\/span><br \/>\ntcp-backlog <span class=\"token number\">511<\/span>                  <span class=\"token comment\"># TCP \u5168\u8fde\u63a5\u961f\u5217<\/span><br \/>\n<span class=\"token function\">timeout<\/span> <span class=\"token number\">300<\/span>                      <span class=\"token comment\"># \u7a7a\u95f2\u8fde\u63a5\u8d85\u65f6&#xff08;0\u4e3a\u4e0d\u8d85\u65f6&#xff09;<\/span><br \/>\ntcp-keepalive <span class=\"token number\">300<\/span>                <span class=\"token comment\"># TCP \u4fdd\u6d3b\u65f6\u95f4<\/span><\/p>\n<p><span class=\"token comment\"># \u5b89\u5168\u914d\u7f6e<\/span><br \/>\nrequirepass your-strong-password <span class=\"token comment\"># \u8bbe\u7f6e\u5bc6\u7801<\/span><br \/>\nrename-command FLUSHALL <span class=\"token string\">&#034;&#034;<\/span>       <span class=\"token comment\"># \u7981\u7528\u5371\u9669\u547d\u4ee4<\/span><br \/>\nrename-command CONFIG <span class=\"token string\">&#034;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u6027\u80fd\u914d\u7f6e<\/span><br \/>\nhz <span class=\"token number\">10<\/span>                            <span class=\"token comment\"># serverCron \u6267\u884c\u9891\u7387&#xff08;\u9ed8\u8ba410&#xff0c;\u9ad8\u8d1f\u8f7d\u53ef\u8c03\u81f3100&#xff09;<\/span><br \/>\nslowlog-log-slower-than <span class=\"token number\">10000<\/span>    <span class=\"token comment\"># \u6162\u67e5\u8be2\u9608\u503c&#xff08;\u5fae\u79d2&#xff09;<\/span><br \/>\nslowlog-max-len <span class=\"token number\">128<\/span>              <span class=\"token comment\"># \u6162\u67e5\u8be2\u65e5\u5fd7\u6700\u5927\u6761\u6570<\/span><\/p>\n<hr \/>\n<h3>\u4e5d\u3001 \u5b89\u88c5\u914d\u7f6e<\/h3>\n<h4>9.1 \u4e0b\u8f7d\u5b89\u88c5<\/h4>\n<p>\u624b\u52a8\u521b\u5efa SCLo-scl \u4ed3\u5e93\u6587\u4ef6<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">vi<\/span> \/etc\/yum.repos.d\/CentOS-SCLo-scl.repo<\/p>\n<p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n<p><span class=\"token punctuation\">[<\/span>centos-sclo-sclo<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">name<\/span><span class=\"token operator\">&#061;<\/span>CentOS-7 &#8211; SCLo sclo<br \/>\n<span class=\"token assign-left variable\">baseurl<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/7\/sclo\/<span class=\"token variable\">$basearch<\/span>\/sclo\/<br \/>\n<span class=\"token assign-left variable\">gpgcheck<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token assign-left variable\">enabled<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token assign-left variable\">gpgkey<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/RPM-GPG-KEY-CentOS-7<\/p>\n<p><span class=\"token punctuation\">[<\/span>centos-sclo-sclo-source<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">name<\/span><span class=\"token operator\">&#061;<\/span>CentOS-7 &#8211; SCLo sclo Sources<br \/>\n<span class=\"token assign-left variable\">baseurl<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/7\/sclo\/Source\/sclo\/<br \/>\n<span class=\"token assign-left variable\">gpgcheck<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token assign-left variable\">enabled<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><br \/>\n<span class=\"token assign-left variable\">gpgkey<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/RPM-GPG-KEY-CentOS-7<\/p>\n<p><span class=\"token punctuation\">[<\/span>centos-sclo-sclo-debuginfo<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">name<\/span><span class=\"token operator\">&#061;<\/span>CentOS-7 &#8211; SCLo sclo Debug<br \/>\n<span class=\"token assign-left variable\">baseurl<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/7\/sclo\/<span class=\"token variable\">$basearch<\/span>\/debug\/sclo\/<br \/>\n<span class=\"token assign-left variable\">gpgcheck<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token assign-left variable\">enabled<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><br \/>\n<span class=\"token assign-left variable\">gpgkey<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/RPM-GPG-KEY-CentOS-7<\/p>\n<p>\u624b\u52a8\u521b\u5efa SCLo-rh \u4ed3\u5e93\u6587\u4ef6&#xff08;devtoolset \u4f9d\u8d56\u6b64\u5e93&#xff09;<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">vi<\/span> \/etc\/yum.repos.d\/CentOS-SCLo-scl-rh.repo<\/p>\n<p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n<p><span class=\"token punctuation\">[<\/span>centos-sclo-rh<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">name<\/span><span class=\"token operator\">&#061;<\/span>CentOS-7 &#8211; SCLo rh<br \/>\n<span class=\"token assign-left variable\">baseurl<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/7\/sclo\/<span class=\"token variable\">$basearch<\/span>\/rh\/<br \/>\n<span class=\"token assign-left variable\">gpgcheck<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token assign-left variable\">enabled<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token assign-left variable\">gpgkey<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/RPM-GPG-KEY-CentOS-7<\/p>\n<p><span class=\"token punctuation\">[<\/span>centos-sclo-rh-source<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">name<\/span><span class=\"token operator\">&#061;<\/span>CentOS-7 &#8211; SCLo rh Sources<br \/>\n<span class=\"token assign-left variable\">baseurl<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/7\/sclo\/Source\/rh\/<br \/>\n<span class=\"token assign-left variable\">gpgcheck<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token assign-left variable\">enabled<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><br \/>\n<span class=\"token assign-left variable\">gpgkey<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/RPM-GPG-KEY-CentOS-7<\/p>\n<p><span class=\"token punctuation\">[<\/span>centos-sclo-rh-debuginfo<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">name<\/span><span class=\"token operator\">&#061;<\/span>CentOS-7 &#8211; SCLo rh Debug<br \/>\n<span class=\"token assign-left variable\">baseurl<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/7\/sclo\/<span class=\"token variable\">$basearch<\/span>\/debug\/rh\/<br \/>\n<span class=\"token assign-left variable\">gpgcheck<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token assign-left variable\">enabled<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><br \/>\n<span class=\"token assign-left variable\">gpgkey<\/span><span class=\"token operator\">&#061;<\/span>https:\/\/mirrors.aliyun.com\/centos\/RPM-GPG-KEY-CentOS-7<\/p>\n<p>\u91cd\u5efa yum \u7f13\u5b58<\/p>\n<p><span class=\"token function\">sudo<\/span> yum clean all<br \/>\n<span class=\"token function\">sudo<\/span> yum makecache<\/p>\n<p>\u5b89\u88c5C\u8bed\u8a00\u7f16\u8bd1\u73af\u5883<\/p>\n<p><span class=\"token function\">sudo<\/span> yum <span class=\"token function\">install<\/span> centos-release-scl scl-utils-build<br \/>\n<span class=\"token function\">sudo<\/span> yum <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> <span class=\"token parameter variable\">&#8211;nogpgcheck<\/span> devtoolset-8-toolchain<br \/>\n<span class=\"token comment\"># \u6ce8\u610f: \u6267\u884c\u6b64\u547d\u4ee4\u4f1a\u81ea\u52a8\u5207\u6362\u5230 root \u7528\u6237<\/span><br \/>\n<span class=\"token function\">sudo<\/span>  scl <span class=\"token builtin class-name\">enable<\/span> devtoolset-8 <span class=\"token function\">bash<\/span><\/p>\n<p>\u6d4b\u8bd5 gcc \u7248\u672c<\/p>\n<p>gcc <span class=\"token parameter variable\">&#8211;version<\/span><\/p>\n<p>\u4e0b\u8f7d\u5730\u5740&#xff1a;https:\/\/download.redis.io\/releases\/ <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260731043313-6a6c25897f867.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e0b\u8f7d\u540e\u4e0a\u4f20\u5230 hadoop1 \u7684 \/opt\/software \u76ee\u5f55\u4e0b&#xff0c;\u5e76\u7528 tar \u547d\u4ee4\u89e3\u538b <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260731043313-6a6c2589c700e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8fdb\u5165\u89e3\u538b\u540e\u7684 redis \u76ee\u5f55\u4f7f\u7528 make \u8fdb\u884c\u7f16\u8bd1 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260731043313-6a6c2589f21de.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7f16\u8bd1\u5b8c\u6210\u540e\u7ee7\u7eed\u6267\u884c make install \u8fdb\u884c\u5b89\u88c5 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260731043314-6a6c258a27c62.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5b89\u88c5\u76ee\u5f55&#xff1a;\/usr\/local\/bin<\/p>\n<h4>9.2 \u540e\u53f0\u542f\u52a8\u914d\u7f6e<\/h4>\n<p>\u4e00\u4efdredis.conf\u5230 hadoop \u5bb6\u76ee\u5f55\u4e0b<\/p>\n<p><span class=\"token function\">cp<\/span> \/opt\/module\/redis-6.0.8\/redis.conf ~\/my_redis.conf<\/p>\n<p>\u4fee\u6539 vim ~\/my_redis.conf \u6587\u4ef6<\/p>\n<p>daemonize <span class=\"token function\">yes<\/span><br \/>\n<span class=\"token comment\"># bind 127.0.0.1  \u6ce8\u91ca\u6389\u8fd9\u4e2a\u914d\u7f6e<\/span><br \/>\nprotected-mode no<\/p>\n<h4>9.3 \u542f\u52a8\u548c\u5173\u95ed<\/h4>\n<p>redis-server ~\/my_redis.conf   <span class=\"token comment\"># \u542f\u52a8<\/span><br \/>\nredis-cli   <span class=\"token comment\"># \u5ba2\u6237\u7aef\u8bbf\u95ee<\/span><br \/>\nredis-cli <span class=\"token function\">shutdown<\/span>             <span class=\"token comment\"># \u5173\u95ed<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260731043314-6a6c258a4c3af.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<hr \/>\n<h3>\u5341\u3001\u5173\u952e\u8981\u70b9\u603b\u7ed3<\/h3>\n<li>\u7eaf\u5185\u5b58 &#043; \u5355\u7ebf\u7a0b\u6267\u884c \u662f Redis \u9ad8\u6027\u80fd\u7684\u57fa\u77f3&#xff0c;\u914d\u5408 IO \u591a\u8def\u590d\u7528\u5b9e\u73b0\u5355\u7ebf\u7a0b\u4e07\u7ea7\u5e76\u53d1<\/li>\n<li>\u4e24\u5c42\u67b6\u6784\u8bbe\u8ba1 \u662f Redis \u6700\u7cbe\u5999\u7684\u8bbe\u8ba1\u4e4b\u4e00\u2014\u2014\u5bf9\u5916\u66b4\u9732 5 \u79cd\u903b\u8f91\u7c7b\u578b&#xff0c;\u5e95\u5c42\u81ea\u52a8\u9009\u62e9\u6700\u4f18\u7269\u7406\u7f16\u7801&#xff08;redisObject \u6865\u63a5 type \u548c encoding&#xff09;<\/li>\n<li>\u8df3\u8868 \u662f ZSet \u7684\u6392\u5e8f\u5f15\u64ce&#xff0c;\u76f8\u6bd4\u7ea2\u9ed1\u6811\u5b9e\u73b0\u66f4\u7b80\u5355\u3001\u8303\u56f4\u67e5\u8be2\u66f4\u9ad8\u6548\u3001\u5185\u5b58\u66f4\u53cb\u597d<\/li>\n<li>\u6301\u4e45\u5316\u9009\u578b \u76f4\u63a5\u5f71\u54cd\u6570\u636e\u5b89\u5168\u6027\u548c\u6027\u80fd\u2014\u2014\u751f\u4ea7\u63a8\u8350\u6df7\u5408\u6301\u4e45\u5316&#xff08;RDB &#043; AOF \u589e\u91cf&#xff09;&#xff0c;\u517c\u987e\u6062\u590d\u901f\u5ea6\u548c\u6570\u636e\u5b8c\u6574\u6027<\/li>\n<li>\u8fc7\u671f\u6e05\u7406 \u91c7\u7528\u60f0\u6027\u5220\u9664 &#043; \u5b9a\u671f\u5220\u9664\u7ec4\u5408\u7b56\u7565&#xff0c;\u662f CPU \u548c\u5185\u5b58\u4e4b\u95f4\u7684\u6298\u4e2d\u8bbe\u8ba1<\/li>\n<li>\u5185\u5b58\u6dd8\u6c70 \u63d0\u4f9b 8 \u79cd\u7b56\u7565&#xff0c;\u7eaf\u7f13\u5b58\u573a\u666f\u63a8\u8350 allkeys-lfu \u6216 allkeys-lru<\/li>\n<li>\u9ad8\u53ef\u7528\u6f14\u8fdb\u8def\u5f84&#xff1a;\u4e3b\u4ece\u590d\u5236&#xff08;\u8bfb\u5199\u5206\u79bb&#xff09;\u2192 \u54e8\u5175\u6a21\u5f0f&#xff08;\u81ea\u52a8\u6545\u969c\u8f6c\u79fb&#xff09;\u2192 Cluster \u96c6\u7fa4&#xff08;\u6c34\u5e73\u6269\u5c55 &#043; \u53bb\u4e2d\u5fc3\u5316\u5206\u7247&#xff09;<\/li>\n<li>\u751f\u4ea7\u5b9e\u8df5 \u9700\u91cd\u70b9\u5173\u6ce8\u7f13\u5b58\u7a7f\u900f\/\u51fb\u7a7f\/\u96ea\u5d29\u7684\u9884\u9632\u3001\u5206\u5e03\u5f0f\u9501\u7684\u6b63\u786e\u5b9e\u73b0\u3001\u5371\u9669\u547d\u4ee4\u7684\u7981\u7528\u3001\u4ee5\u53ca\u6162\u67e5\u8be2\u7684\u6301\u7eed\u76d1\u63a7<\/li>\n","protected":false},"excerpt":{"rendered":"<p>Redis \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8e\u5185\u5b58\u7684\u9ad8\u6027\u80fd\u952e\u503c\u5b58\u50a8\u6570\u636e\u5e93&#xff0c;\u652f\u6301\u4e30\u5bcc\u7684\u6570\u636e\u7ed3\u6784\u7c7b\u578b&#xff0c;\u5355\u8282\u70b9 QPS \u53ef\u8fbe 10 \u4e07&#xff0c;\u8bfb\u5199\u5ef6\u8fdf\u4f4e\u81f3\u4e9a\u6beb\u79d2\u7ea7\u522b\u3002\u672c\u6587\u4ece Redis \u7684\u6838\u5fc3\u67b6\u6784\u3001\u6570\u636e\u7ed3\u6784\u3001\u6301\u4e45\u5316\u673a\u5236\u3001\u5185\u5b58\u7ba1\u7406\u3001\u9ad8\u53ef\u7528\u65b9\u6848\u7b49\u7ef4\u5ea6\u8fdb\u884c\u7cfb\u7edf\u6027\u7684\u6df1\u5ea6\u5256\u6790\u3002 \u4e00\u3001Redis \u6982\u8ff0<br \/>\n1.1 \u4ec0\u4e48\u662f Redis<br \/>\nRedis&#xff08;Remote Dictionary Server&#xff09;\u662f\u4e00\u4e2a\u57fa\u4e8e\u5185\u5b58\u7684\u952e\u503c\u5b58\u50a8\u7cfb\u7edf&#xff0c;\u7531 Sa<\/p>\n","protected":false},"author":2,"featured_media":88042,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[105,323,2330,100,188],"topic":[],"class_list":["post-88047","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-redis","tag-323","tag-2330","tag-100","tag-188"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/88047.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Redis \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8e\u5185\u5b58\u7684\u9ad8\u6027\u80fd\u952e\u503c\u5b58\u50a8\u6570\u636e\u5e93&#xff0c;\u652f\u6301\u4e30\u5bcc\u7684\u6570\u636e\u7ed3\u6784\u7c7b\u578b&#xff0c;\u5355\u8282\u70b9 QPS \u53ef\u8fbe 10 \u4e07&#xff0c;\u8bfb\u5199\u5ef6\u8fdf\u4f4e\u81f3\u4e9a\u6beb\u79d2\u7ea7\u522b\u3002\u672c\u6587\u4ece Redis \u7684\u6838\u5fc3\u67b6\u6784\u3001\u6570\u636e\u7ed3\u6784\u3001\u6301\u4e45\u5316\u673a\u5236\u3001\u5185\u5b58\u7ba1\u7406\u3001\u9ad8\u53ef\u7528\u65b9\u6848\u7b49\u7ef4\u5ea6\u8fdb\u884c\u7cfb\u7edf\u6027\u7684\u6df1\u5ea6\u5256\u6790\u3002 \u4e00\u3001Redis \u6982\u8ff0 1.1 \u4ec0\u4e48\u662f Redis Redis&#xff08;Remote Dictionary Server&#xff09;\u662f\u4e00\u4e2a\u57fa\u4e8e\u5185\u5b58\u7684\u952e\u503c\u5b58\u50a8\u7cfb\u7edf&#xff0c;\u7531 Sa\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/88047.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-31T04:33:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260731043313-6a6c25897f867.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/88047.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/88047.html\",\"name\":\"\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-31T04:33:15+00:00\",\"dateModified\":\"2026-07-31T04:33:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/88047.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/88047.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/88047.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/88047.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Redis \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8e\u5185\u5b58\u7684\u9ad8\u6027\u80fd\u952e\u503c\u5b58\u50a8\u6570\u636e\u5e93&#xff0c;\u652f\u6301\u4e30\u5bcc\u7684\u6570\u636e\u7ed3\u6784\u7c7b\u578b&#xff0c;\u5355\u8282\u70b9 QPS \u53ef\u8fbe 10 \u4e07&#xff0c;\u8bfb\u5199\u5ef6\u8fdf\u4f4e\u81f3\u4e9a\u6beb\u79d2\u7ea7\u522b\u3002\u672c\u6587\u4ece Redis \u7684\u6838\u5fc3\u67b6\u6784\u3001\u6570\u636e\u7ed3\u6784\u3001\u6301\u4e45\u5316\u673a\u5236\u3001\u5185\u5b58\u7ba1\u7406\u3001\u9ad8\u53ef\u7528\u65b9\u6848\u7b49\u7ef4\u5ea6\u8fdb\u884c\u7cfb\u7edf\u6027\u7684\u6df1\u5ea6\u5256\u6790\u3002 \u4e00\u3001Redis \u6982\u8ff0 1.1 \u4ec0\u4e48\u662f Redis Redis&#xff08;Remote Dictionary Server&#xff09;\u662f\u4e00\u4e2a\u57fa\u4e8e\u5185\u5b58\u7684\u952e\u503c\u5b58\u50a8\u7cfb\u7edf&#xff0c;\u7531 Sa","og_url":"https:\/\/www.wsisp.com\/helps\/88047.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-31T04:33:15+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260731043313-6a6c25897f867.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/88047.html","url":"https:\/\/www.wsisp.com\/helps\/88047.html","name":"\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-31T04:33:15+00:00","dateModified":"2026-07-31T04:33:15+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/88047.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/88047.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/88047.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5341\u4e03\u3001Redis \u6838\u5fc3\u539f\u7406\u4e0e\u67b6\u6784\u8be6\u89e3"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/88047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=88047"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/88047\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/88042"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=88047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=88047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=88047"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=88047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}