{"id":62227,"date":"2024-10-13T17:14:14","date_gmt":"2024-10-13T09:14:14","guid":{"rendered":"https:\/\/server.hk\/cnblog\/62227\/"},"modified":"2024-10-13T17:14:14","modified_gmt":"2024-10-13T09:14:14","slug":"keys%e5%a6%82%e4%bd%95%e5%bf%ab%e9%80%9f%e6%b8%85%e9%99%a4%e6%89%80%e6%9c%89redis%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ad%e7%9a%84keys%ef%bc%88%e5%a6%82%e4%bd%95%e6%b8%85%e9%99%a4%e6%89%80%e6%9c%89redis","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/62227\/","title":{"rendered":"Keys\u5982\u4f55\u5feb\u901f\u6e05\u9664\u6240\u6709Redis\u6578\u64da\u5eab\u4e2d\u7684Keys\uff08\u5982\u4f55\u6e05\u9664\u6240\u6709redis\uff09"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e5%bf%ab%e9%80%9f%e6%b8%85%e9%99%a4%e6%89%80%e6%9c%89redis%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ad%e7%9a%84keys-hecGSohXEz\">\u5982\u4f55\u5feb\u901f\u6e05\u9664\u6240\u6709Redis\u6578\u64da\u5eab\u4e2d\u7684Keys<\/h1>\n<p>Redis\u662f\u4e00\u7a2e\u9ad8\u6548\u7684\u9375\u503c\u6578\u64da\u5eab\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u7de9\u5b58\u3001\u6d88\u606f\u968a\u5217\u548c\u6578\u64da\u5b58\u5132\u7b49\u5834\u666f\u3002\u96a8\u8457\u6642\u9593\u7684\u63a8\u79fb\uff0c\u6578\u64da\u5eab\u4e2d\u53ef\u80fd\u6703\u7a4d\u7d2f\u5927\u91cf\u7684Keys\uff0c\u9019\u53ef\u80fd\u6703\u5f71\u97ff\u6027\u80fd\u6216\u5c0e\u81f4\u5b58\u5132\u7a7a\u9593\u4e0d\u8db3\u3002\u56e0\u6b64\uff0c\u5b9a\u671f\u6e05\u9664\u4e0d\u518d\u9700\u8981\u7684Keys\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5e7e\u7a2e\u5feb\u901f\u6e05\u9664Redis\u6578\u64da\u5eab\u4e2d\u6240\u6709Keys\u7684\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8redis%e5%91%bd%e4%bb%a4%e6%b8%85%e9%99%a4keys-hecGSohXEz\">\u4f7f\u7528Redis\u547d\u4ee4\u6e05\u9664Keys<\/h2>\n<p>Redis\u63d0\u4f9b\u4e86\u591a\u7a2e\u547d\u4ee4\u4f86\u7ba1\u7406Keys\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u547d\u4ee4\u662f <code id=\"flushdb-hecGSohXEz\">FLUSHDB<\/code> \u548c <code id=\"flushall-hecGSohXEz\">FLUSHALL<\/code>\u3002<\/p>\n<h3 id=\"flushdb-hecGSohXEz\">FLUSHDB<\/h3>\n<p><code id=\"flushdb-hecGSohXEz\">FLUSHDB<\/code> \u547d\u4ee4\u7528\u65bc\u6e05\u9664\u7576\u524d\u6578\u64da\u5eab\u4e2d\u7684\u6240\u6709Keys\u3002\u9019\u500b\u547d\u4ee4\u975e\u5e38\u7c21\u55ae\uff0c\u53ea\u9700\u5728Redis\u547d\u4ee4\u884c\u754c\u9762\u4e2d\u8f38\u5165\uff1a<\/p>\n<pre><code id=\"flushdb-hecGSohXEz\">FLUSHDB<\/code><\/pre>\n<p>\u57f7\u884c\u6b64\u547d\u4ee4\u5f8c\uff0c\u7576\u524d\u6578\u64da\u5eab\u4e2d\u7684\u6240\u6709Keys\u5c07\u88ab\u522a\u9664\uff0c\u7121\u6cd5\u6062\u5fa9\u3002\u56e0\u6b64\uff0c\u5728\u57f7\u884c\u6b64\u64cd\u4f5c\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u4e0d\u518d\u9700\u8981\u9019\u4e9b\u6578\u64da\u3002<\/p>\n<h3 id=\"flushall-hecGSohXEz\">FLUSHALL<\/h3>\n<p>\u5982\u679c\u60a8\u5e0c\u671b\u6e05\u9664\u6240\u6709\u6578\u64da\u5eab\u4e2d\u7684\u6240\u6709Keys\uff0c\u53ef\u4ee5\u4f7f\u7528 <code id=\"flushall-hecGSohXEz\">FLUSHALL<\/code> \u547d\u4ee4\u3002\u9019\u500b\u547d\u4ee4\u6703\u522a\u9664Redis\u5be6\u4f8b\u4e2d\u7684\u6240\u6709\u6578\u64da\u5eab\u7684Keys\uff1a<\/p>\n<pre><code id=\"flushall-hecGSohXEz\">FLUSHALL<\/code><\/pre>\n<p>\u540c\u6a23\uff0c\u9019\u500b\u64cd\u4f5c\u662f\u4e0d\u53ef\u9006\u7684\uff0c\u8acb\u8b39\u614e\u4f7f\u7528\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8redis%e5%ae%a2%e6%88%b6%e7%ab%af%e5%b7%a5%e5%85%b7-hecGSohXEz\">\u4f7f\u7528Redis\u5ba2\u6236\u7aef\u5de5\u5177<\/h2>\n<p>\u9664\u4e86\u4f7f\u7528\u547d\u4ee4\u884c\uff0c\u9084\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9bRedis\u5ba2\u6236\u7aef\u5de5\u5177\u4f86\u6e05\u9664Keys\u3002\u4f8b\u5982\uff0cRedis Desktop Manager\u548cRedisInsight\u7b49\u5de5\u5177\u63d0\u4f9b\u4e86\u5716\u5f62\u754c\u9762\uff0c\u8b93\u7528\u6236\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u7ba1\u7406Keys\u3002<\/p>\n<h3 id=\"redis-desktop-manager-hecGSohXEz\">Redis Desktop Manager<\/h3>\n<ul>\n<li>\u6253\u958bRedis Desktop Manager\uff0c\u9023\u63a5\u5230\u60a8\u7684Redis\u670d\u52d9\u5668\u3002<\/li>\n<li>\u9078\u64c7\u8981\u6e05\u9664\u7684\u6578\u64da\u5eab\u3002<\/li>\n<li>\u5728Keys\u5217\u8868\u4e2d\uff0c\u9078\u64c7\u6240\u6709Keys\uff0c\u7136\u5f8c\u53f3\u9375\u9078\u64c7\u522a\u9664\u3002<\/li>\n<\/ul>\n<h3 id=\"redisinsight-hecGSohXEz\">RedisInsight<\/h3>\n<ul>\n<li>\u555f\u52d5RedisInsight\u4e26\u9023\u63a5\u5230Redis\u670d\u52d9\u5668\u3002<\/li>\n<li>\u5c0e\u822a\u5230Keys\u9078\u9805\u5361\uff0c\u9078\u64c7\u8981\u522a\u9664\u7684Keys\u3002<\/li>\n<li>\u9ede\u64ca\u522a\u9664\u6309\u9215\u4ee5\u6e05\u9664\u9078\u5b9a\u7684Keys\u3002<\/li>\n<\/ul>\n<h2 id=\"%e4%bd%bf%e7%94%a8%e8%85%b3%e6%9c%ac%e8%87%aa%e5%8b%95%e6%b8%85%e9%99%a4keys-hecGSohXEz\">\u4f7f\u7528\u8173\u672c\u81ea\u52d5\u6e05\u9664Keys<\/h2>\n<p>\u5982\u679c\u60a8\u9700\u8981\u5b9a\u671f\u6e05\u9664Keys\uff0c\u53ef\u4ee5\u8003\u616e\u7de8\u5beb\u4e00\u500b\u7c21\u55ae\u7684\u8173\u672c\u4f86\u81ea\u52d5\u57f7\u884c\u9019\u4e00\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528Python\u548cRedis-py\u5eab\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>import redis\n\n# \u9023\u63a5\u5230Redis\nr = redis.Redis(host='localhost', port=6379, db=0)\n\n# \u6e05\u9664\u7576\u524d\u6578\u64da\u5eab\u4e2d\u7684\u6240\u6709Keys\nr.flushdb()\n<\/code><\/pre>\n<p>\u9019\u6bb5\u4ee3\u78bc\u5c07\u9023\u63a5\u5230\u672c\u5730\u7684Redis\u670d\u52d9\u5668\u4e26\u6e05\u9664\u7576\u524d\u6578\u64da\u5eab\u4e2d\u7684\u6240\u6709Keys\u3002\u60a8\u53ef\u4ee5\u6839\u64da\u9700\u8981\u8abf\u6574\u9023\u63a5\u53c3\u6578\u3002<\/p>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-hecGSohXEz\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u6e05\u9664Keys\u4e4b\u524d\uff0c\u8acb\u52d9\u5fc5\u8003\u616e\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u78ba\u4fdd\u60a8\u4e0d\u518d\u9700\u8981\u9019\u4e9b\u6578\u64da\uff0c\u56e0\u70ba\u4e00\u65e6\u522a\u9664\u5c07\u7121\u6cd5\u6062\u5fa9\u3002<\/li>\n<li>\u5728\u751f\u7522\u74b0\u5883\u4e2d\uff0c\u5efa\u8b70\u5148\u5099\u4efd\u6578\u64da\uff0c\u4ee5\u9632\u610f\u5916\u522a\u9664\u91cd\u8981\u4fe1\u606f\u3002<\/li>\n<li>\u5b9a\u671f\u6e05\u7406\u4e0d\u5fc5\u8981\u7684Keys\u53ef\u4ee5\u63d0\u9ad8Redis\u7684\u6027\u80fd\u548c\u6548\u7387\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-hecGSohXEz\">\u7e3d\u7d50<\/h2>\n<p>\u6e05\u9664Redis\u6578\u64da\u5eab\u4e2d\u7684Keys\u662f\u4e00\u500b\u7c21\u55ae\u4f46\u91cd\u8981\u7684\u64cd\u4f5c\u3002\u7121\u8ad6\u662f\u4f7f\u7528\u547d\u4ee4\u884c\u3001\u5ba2\u6236\u7aef\u5de5\u5177\u9084\u662f\u81ea\u52d5\u5316\u8173\u672c\uff0c\u90fd\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u548c\u6e05\u7406\u6578\u64da\u3002\u5b9a\u671f\u9032\u884c\u9019\u4e9b\u64cd\u4f5c\u4e0d\u50c5\u80fd\u5920\u91cb\u653e\u5b58\u5132\u7a7a\u9593\uff0c\u9084\u80fd\u63d0\u9ad8\u7cfb\u7d71\u6027\u80fd\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684Redis\u670d\u52d9\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684\u670d\u52d9\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u9084\u662f\u5176\u4ed6 <a href=\"https:\/\/server.hk\">\u4e91\u670d\u52a1\u5668<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u6211\u5011\u90fd\u80fd\u63d0\u4f9b\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5feb\u901f\u6e05\u9664\u6240\u6709Redis\u6578\u64da\u5eab\u4e2d\u7684Keys\uff0c\u7c21\u55ae\u6b65\u9a5f\u6559\u4f60\u5982\u4f55\u6709\u6548\u7ba1\u7406Redis\u6578\u64da\uff0c\u4fdd\u6301\u6578\u64da\u5eab\u6574\u6f54\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-62227","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/62227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=62227"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/62227\/revisions"}],"predecessor-version":[{"id":62228,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/62227\/revisions\/62228"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=62227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=62227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=62227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}