{"id":43667,"date":"2024-12-01T09:13:27","date_gmt":"2024-12-01T01:13:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/43667\/"},"modified":"2024-12-01T09:13:27","modified_gmt":"2024-12-01T01:13:27","slug":"redis%e5%85%a5%e9%97%a8%e5%9f%ba%e7%a1%80%e5%b8%b8%e7%94%a8%e6%93%8d%e4%bd%9c%e5%91%bd%e4%bb%a4%e6%95%b4%e7%90%86","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/43667\/","title":{"rendered":"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406<\/h1>\n<p><span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u6765\u5230golang\u5b66\u4e60\u7f51\u7684\u5927\u5bb6\uff0c\u76f8\u4fe1\u90fd\u662f\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5e0c\u671b\u5728\u8fd9\u91cc\u5b66\u4e60\u6570\u636e\u5e93\u76f8\u5173\u7f16\u7a0b\u77e5\u8bc6\u3002\u4e0b\u9762\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u5e26\u5927\u5bb6\u804a\u804a\u300aRedis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u300b\uff0c\u4ecb\u7ecd\u4e00\u4e0b\u64cd\u4f5c\u547d\u4ee4\u3001Redis\u57fa\u7840\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<h2>Redis\u57fa\u7840<\/h2>\n<p>Redis \u662f\u4e00\u4e2a\u5f00\u6e90(BSD\u8bb8\u53ef)\u7684\uff0c\u5185\u5b58\u4e2d\u7684\u6570\u636e\u7ed3\u6784\u5b58\u50a8\u7cfb\u7edf\uff0c\u5b83\u53ef\u4ee5\u7528\u4f5c\u6570\u636e\u5e93\u3001\u7f13\u5b58\u548c\u6d88\u606f\u4e2d\u95f4\u4ef6\u3002\u5b83\u652f\u6301\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5982\u5b57\u7b26\u4e32(strings)\uff0c\u6563\u5217(hashes)\uff0c\u5217\u8868(lists)\uff0c\u96c6\u5408(sets)\uff0c\u6709\u5e8f\u96c6\u5408(sorted sets)\u4e0e\u8303\u56f4\u67e5\u8be2\uff0cbitmaps\uff0chyperloglogs \u548c\u5730\u7406\u7a7a\u95f4(geospatial) \u7d22\u5f15\u534a\u5f84\u67e5\u8be2\u3002<\/p>\n<p>Redis \u5185\u7f6e\u4e86\u590d\u5236(replication)\uff0cLUA\u811a\u672c(Lua scripting)\uff0cLRU\u9a71\u52a8\u4e8b\u4ef6(LRU eviction)\uff0c\u4e8b\u52a1(transactions)\u548c\u4e0d\u540c\u7ea7\u522b\u7684\u78c1\u76d8\u6301\u4e45\u5316(persistence)\uff0c\u5e76\u901a\u8fc7Redis\u54e8\u5175(Sentinel)\u548c\u81ea\u52a8 \u5206\u533a(Cluster)\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027(high availability)\u3002<\/p>\n<h3>\u4e00\u3001redis\u662f\u5355\u7ebf\u7a0b<\/h3>\n<p>redis\u662f\u57fa\u4e8e\u5185\u5b58\u64cd\u4f5c\u7684\uff0ccpu\u5e76\u4e0d\u662fredis\u7684\u6027\u80fd\u74f6\u9888\uff0c\u5b83\u7684\u74f6\u9888\u53d6\u51b3\u4e8e\u673a\u5668\u7684\u5185\u5b58\u548c\u7f51\u7edc\u5e26\u5bbd\uff0c\u6240\u4ee5\u80fd\u7528\u5355\u7ebf\u7a0b\u5b9e\u73b0\u90a3\u5c31\u7528\u5355\u7ebf\u7a0b\u597d\u4e86\u3002<\/p>\n<p>\u90a3\u4e48\u4e3a\u4ec0\u4e48\u7528\u5355\u7ebf\u7a0b\u8fd8\u80fd\u8fd9\u4e48\u5feb\uff1f<\/p>\n<p>\u9996\u5148\u67092\u4e2a\u8bef\u533a\u5148\u8981\u660e\u786e\uff1a<\/p>\n<ul>\n<li>\u9ad8\u6027\u80fd\u7684\u670d\u52a1\u5668\u4e0d\u4e00\u5b9a\u662f\u591a\u7ebf\u7a0b\u7684\u3002<\/li>\n<li>\u591a\u7ebf\u7a0b\u4e5f\u4e0d\u662f\u4e00\u5b9a\u6bd4\u5355\u7ebf\u7a0b\u6548\u7387\u9ad8\u3002<\/li>\n<\/ul>\n<p>redis\u662f\u5c06\u6240\u6709\u7684\u6570\u636e\u653e\u5230\u5185\u5b58\u91cc\u53bb\uff0c\u591a\u7ebf\u7a0b\u7684\u8bdd\u53cd\u800c\u4f1a\u5b58\u5728cpu\u5207\u6362\u4e0a\u4e0b\u6587\u4ece\u800c\u589e\u52a0\u8017\u65f6\uff0c\u800c\u5bf9\u5185\u5b58\u7cfb\u7edf\u6765\u8bf4\uff0c\u6ca1\u6709\u4e0a\u4e0b\u6587\u7684\u5207\u6362\uff0c\u5355\u7ebf\u7a0b\u64cd\u4f5c\u6548\u7387\u5c31\u662f\u6700\u9ad8\u7684\u3002<\/p>\n<h3>\u4e8c\u3001\u5173\u4e8e\u6570\u636e\u5e93\u7684\u5e38\u7528\u64cd\u4f5c<\/h3>\n<h4>1. \u9ed8\u8ba4\u6570\u636e\u5e93<\/h4>\n<p>redis\u9ed8\u8ba4\u670916\u4e2a\u6570\u636e\u5e93\uff0c\u9ed8\u8ba4\u4f7f\u7528\u662f\u7b2c\u4e00\u4e2a\u6570\u636e\u5e93(\u4e0b\u6807\u4e3a0)\u3002\u53ef\u4ee5\u67e5\u770b\u4e0b\u914d\u7f6e\u6587\u4ef6\uff0c\u91cc\u9762\u6709<code>database 16<\/code>\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733763afd389537b4.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe\" \/><\/p>\n<h4>2. \u5207\u6362\u6570\u636e\u5e93<\/h4>\n<p><code>select 3<\/code>\uff0c\u53ef\u4ee5\u5207\u6362\u5230\u7b2c4\u4e2a\u6570\u636e\u5e93\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733763afd38980b24.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe1\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe1\" \/><\/p>\n<h4>3. \u67e5\u770b\u6570\u636e\u5e93\u5927\u5c0f<\/h4>\n<p><code>dbsize<\/code>\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u5927\u5c0f\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733763afd389bfe5a.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe2\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe2\" \/><\/p>\n<p>\u8fd9\u65f6\uff0c\u7ed9\u6570\u636e\u5e93\u91ccset\u4e00\u4e2a\u503c\uff0c\u518d\u6b21\u67e5\u770b\u6570\u636e\u5e93\u5927\u5c0f\uff0c\u5c31\u53d8\u5316\u4e86\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733863afd38a08fce.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe3\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe3\" \/><\/p>\n<h4>4. \u6e05\u7a7a\u6570\u636e\u5e93<\/h4>\n<p>\u6e05\u7a7a\u5f53\u524d\u7684\u6570\u636e\u5e93<\/p>\n<pre>flushdb<\/pre>\n<p>\u6e05\u7a7a\u6240\u6709\u7684\u6570\u636e\u5e93<\/p>\n<pre>flushall<\/pre>\n<h3>\u4e09\u3001\u5173\u4e8eRedis-Key\u7684\u5e38\u7528\u64cd\u4f5c<\/h3>\n<h4>1. set \u8bbe\u7f6ekey \u548c value<\/h4>\n<pre>set name pingguo222<\/pre>\n<h4>2. keys * \u67e5\u770b\u6240\u6709\u7684key<\/h4>\n<p>\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u7684key\u3002\u8fd9\u91cc\u5207\u6362\u56de\u9ed8\u8ba4\u7684\u6570\u636e\u5e93\uff0c\u67e5\u770b\u6240\u6709key\u3002<\/p>\n<pre>keys *<\/pre>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733863afd38a2fe66.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe4\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe4\" \/><\/p>\n<h4>3. get key \u7684 value<\/h4>\n<pre>get name<\/pre>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733863afd38a67308.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe5\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe5\" \/><\/p>\n<h4>4. exists key \u662f\u5426\u5b58\u5728key<\/h4>\n<pre>exists name<\/pre>\n<p>\u5b58\u5728\uff0c\u5219\u8fd4\u56de1\uff0c\u4e0d\u5b58\u5728\u5219\u8fd4\u56de0\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733963afd38b4626a.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe6\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe6\" \/><\/p>\n<h4>5. move \u79fb\u52a8 key<\/h4>\n<p>MOVE \u547d\u4ee4\u662f\u5c06\u5f53\u524d\u6570\u636e\u5e93\u7684 key \u79fb\u52a8\u5230\u7ed9\u5b9a\u7684\u6570\u636e\u5e93 db \u5f53\u4e2d\u3002<\/p>\n<pre>move name 0<\/pre>\n<p>\u6bd4\u5982\u5f53\u524d\u6240\u57283\u6570\u636e\u5e93\uff0c\u547d\u4ee4\u662f \u628a\u5f53\u524d3\u6570\u636e\u5e93\u4e0b\u7684name\u79fb\u52a8\u5230 0\u6570\u636e\u5e93\u4e0b\u3002\u5982\u679c\u6210\u529f\u4e86\u8fd4\u56de1\uff0c\u5931\u8d25\u4e86\u8fd4\u56de0\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733963afd38b9d2c8.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe7\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe7\" \/><\/p>\n<h4>6. \u8bbe\u7f6ekey\u8fc7\u671f\u65f6\u95f4<\/h4>\n<p>\u6211\u8bbe\u7f6eage 10s\u540e\u8fc7\u671f\uff0c\u7b4910s\u540e\u518d\u6b21get\u5c31\u62ff\u4e0d\u5230\u503c\u4e86\u3002<\/p>\n<pre>expire age 10<\/pre>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246733963afd38bcfb4f.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe8\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe8\" \/><\/p>\n<h4>7. \u67e5\u770bkey\u7684\u5269\u4f59\u65f6\u95f4<\/h4>\n<p>\u6211\u8bbe\u7f6ename\u8fc7\u671f\u65f6\u95f4100s\uff0c\u4f7f\u7528ttl\u67e5\u770b\u3002<\/p>\n<pre>ttl name<\/pre>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246734063afd38c0887a.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe9\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe9\" \/><\/p>\n<h4>8. \u67e5\u770bkey\u7684\u7c7b\u578b<\/h4>\n<pre>type name<\/pre>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246734063afd38c3d6c0.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe10\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe10\" \/><\/p>\n<p>\u547d\u4ee4\u5b9e\u9645\u4e0a\u6709\u5f88\u591a\uff0c\u63d0\u4f9b\u4e86\u67e5\u8be2\u547d\u4ee4\u7684\u5730\u65b9\uff0c\u540e\u9762\u5565\u4e0d\u4f1a\u5c31\u67e5\u5565\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20221231\/167246734063afd38c88568.png\" class=\"aligncenter\" title=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe11\" alt=\"Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u63d2\u56fe11\" \/><\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300aRedis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8golang\u5b66\u4e60\u7f51\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6570\u636e\u5e93\u77e5\u8bc6\uff01<\/p>\n<p>    \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1a\u811a\u672c\u4e4b\u5bb6 \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664  <\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   redis\u79d2\u6740\u7cfb\u7edf\u7684\u5b9e\u73b0\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   Redis\u57fa\u672c\u6570\u636e\u7c7b\u578bString\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Redis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406 0\u6d4f\u89c8 \u6536\u85cf \u6765\u5230golang\u5b66\u4e60\u7f51\u7684\u5927\u5bb6\uff0c\u76f8\u4fe1\u90fd\u662f\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5e0c\u671b\u5728\u8fd9\u91cc\u5b66\u4e60\u6570\u636e\u5e93\u76f8\u5173\u7f16\u7a0b\u77e5\u8bc6\u3002\u4e0b\u9762\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u5e26\u5927\u5bb6\u804a\u804a\u300aRedis\u5165\u95e8\u57fa\u7840\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\u6574\u7406\u300b\uff0c\u4ecb\u7ecd\u4e00\u4e0b\u64cd\u4f5c\u547d\u4ee4\u3001Redis\u57fa\u7840\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01 Redis\u57fa\u7840 Redis \u662f\u4e00\u4e2a\u5f00\u6e90(BSD\u8bb8\u53ef)\u7684\uff0c\u5185\u5b58\u4e2d\u7684\u6570\u636e\u7ed3\u6784\u5b58\u50a8\u7cfb\u7edf\uff0c\u5b83\u53ef\u4ee5\u7528\u4f5c\u6570\u636e\u5e93\u3001\u7f13\u5b58\u548c\u6d88\u606f\u4e2d\u95f4\u4ef6\u3002\u5b83\u652f\u6301\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5982\u5b57\u7b26\u4e32(strings)\uff0c\u6563\u5217(hashes)\uff0c\u5217\u8868(lists)\uff0c\u96c6\u5408(sets)\uff0c\u6709\u5e8f\u96c6\u5408(sorted sets)\u4e0e\u8303\u56f4\u67e5\u8be2\uff0cbitmaps\uff0chyperloglogs \u548c\u5730\u7406\u7a7a\u95f4(geospatial) \u7d22\u5f15\u534a\u5f84\u67e5\u8be2\u3002 Redis \u5185\u7f6e\u4e86\u590d\u5236(replication)\uff0cLUA\u811a\u672c(Lua scripting)\uff0cLRU\u9a71\u52a8\u4e8b\u4ef6(LRU eviction)\uff0c\u4e8b\u52a1(transactions)\u548c\u4e0d\u540c\u7ea7\u522b\u7684\u78c1\u76d8\u6301\u4e45\u5316(persistence)\uff0c\u5e76\u901a\u8fc7Redis\u54e8\u5175(Sentinel)\u548c\u81ea\u52a8 \u5206\u533a(Cluster)\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027(high availability)\u3002 \u4e00\u3001redis\u662f\u5355\u7ebf\u7a0b redis\u662f\u57fa\u4e8e\u5185\u5b58\u64cd\u4f5c\u7684\uff0ccpu\u5e76\u4e0d\u662fredis\u7684\u6027\u80fd\u74f6\u9888\uff0c\u5b83\u7684\u74f6\u9888\u53d6\u51b3\u4e8e\u673a\u5668\u7684\u5185\u5b58\u548c\u7f51\u7edc\u5e26\u5bbd\uff0c\u6240\u4ee5\u80fd\u7528\u5355\u7ebf\u7a0b\u5b9e\u73b0\u90a3\u5c31\u7528\u5355\u7ebf\u7a0b\u597d\u4e86\u3002 \u90a3\u4e48\u4e3a\u4ec0\u4e48\u7528\u5355\u7ebf\u7a0b\u8fd8\u80fd\u8fd9\u4e48\u5feb\uff1f \u9996\u5148\u67092\u4e2a\u8bef\u533a\u5148\u8981\u660e\u786e\uff1a \u9ad8\u6027\u80fd\u7684\u670d\u52a1\u5668\u4e0d\u4e00\u5b9a\u662f\u591a\u7ebf\u7a0b\u7684\u3002 \u591a\u7ebf\u7a0b\u4e5f\u4e0d\u662f\u4e00\u5b9a\u6bd4\u5355\u7ebf\u7a0b\u6548\u7387\u9ad8\u3002 redis\u662f\u5c06\u6240\u6709\u7684\u6570\u636e\u653e\u5230\u5185\u5b58\u91cc\u53bb\uff0c\u591a\u7ebf\u7a0b\u7684\u8bdd\u53cd\u800c\u4f1a\u5b58\u5728cpu\u5207\u6362\u4e0a\u4e0b\u6587\u4ece\u800c\u589e\u52a0\u8017\u65f6\uff0c\u800c\u5bf9\u5185\u5b58\u7cfb\u7edf\u6765\u8bf4\uff0c\u6ca1\u6709\u4e0a\u4e0b\u6587\u7684\u5207\u6362\uff0c\u5355\u7ebf\u7a0b\u64cd\u4f5c\u6548\u7387\u5c31\u662f\u6700\u9ad8\u7684\u3002 \u4e8c\u3001\u5173\u4e8e\u6570\u636e\u5e93\u7684\u5e38\u7528\u64cd\u4f5c 1. \u9ed8\u8ba4\u6570\u636e\u5e93 redis\u9ed8\u8ba4\u670916\u4e2a\u6570\u636e\u5e93\uff0c\u9ed8\u8ba4\u4f7f\u7528\u662f\u7b2c\u4e00\u4e2a\u6570\u636e\u5e93(\u4e0b\u6807\u4e3a0)\u3002\u53ef\u4ee5\u67e5\u770b\u4e0b\u914d\u7f6e\u6587\u4ef6\uff0c\u91cc\u9762\u6709database 16\u3002 2. \u5207\u6362\u6570\u636e\u5e93 select 3\uff0c\u53ef\u4ee5\u5207\u6362\u5230\u7b2c4\u4e2a\u6570\u636e\u5e93\u3002 3. \u67e5\u770b\u6570\u636e\u5e93\u5927\u5c0f dbsize\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u5927\u5c0f\u3002 \u8fd9\u65f6\uff0c\u7ed9\u6570\u636e\u5e93\u91ccset\u4e00\u4e2a\u503c\uff0c\u518d\u6b21\u67e5\u770b\u6570\u636e\u5e93\u5927\u5c0f\uff0c\u5c31\u53d8\u5316\u4e86\u3002 4. \u6e05\u7a7a\u6570\u636e\u5e93 \u6e05\u7a7a\u5f53\u524d\u7684\u6570\u636e\u5e93 flushdb \u6e05\u7a7a\u6240\u6709\u7684\u6570\u636e\u5e93 flushall \u4e09\u3001\u5173\u4e8eRedis-Key\u7684\u5e38\u7528\u64cd\u4f5c 1. set \u8bbe\u7f6ekey \u548c value set name pingguo222 2. keys * \u67e5\u770b\u6240\u6709\u7684key [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-43667","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/43667","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=43667"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/43667\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=43667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=43667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=43667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}