{"id":1256,"date":"2021-07-30T14:20:59","date_gmt":"2021-07-30T06:20:59","guid":{"rendered":"https:\/\/egonlin.com\/?p=1256"},"modified":"2024-04-06T16:46:03","modified_gmt":"2024-04-06T08:46:03","slug":"%e7%ac%ac%e4%b8%80%e8%8a%82%ef%bc%9a%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=1256","title":{"rendered":"\u7b2c\u4e00\u8282\uff1a\u5b57\u7b26\u4e32\u6570\u636e\u7ed3\u6784"},"content":{"rendered":"<p><strong>\u767b\u5f55\u89c4\u8303<\/strong><\/p>\n<pre><code class=\"language-bash\">redis-cli -h IP -p PORT --raw\n  -h        # \u4e3b\u673aIP\n  -p        # \u7aef\u53e3\n  --raw     # \u907f\u514d\u4e2d\u6587\u4e71\u7801<\/code><\/pre>\n<h2>\u4e00\u3001string\u5b57\u7b26\u4e32\u6570\u636e\u7ed3\u6784<\/h2>\n<h3>1\u3001\u7279\u70b9<\/h3>\n<pre><code class=\"language-bash\">key value \nnum 10<\/code><\/pre>\n<h3>2\u3001\u4f7f\u7528\u573a\u666f<\/h3>\n<pre><code class=\"language-bash\">    1\u3001\u4f1a\u8bdd\u7f13\u5b58(\u767b\u5f55\u2f79\u7ad9\u4f1a\u8bdd, \u7f13\u5b58\u7684\u4fdd\u7559, \u4f7f\u2f64\u672c\u5730cookie, \u6216\u8005memcache, redis\u8bb0\u5f55hash\u503c, \u5b58 \u952e\u503c\u5bf9) \n    2\u3001\u8ba1\u6570\u5668(\u76f4\u64ad\u7c7b\u5e73\u53f0\u70b9\u51fb\u91cf, \u5173\u6ce8\u91cf), \u5982\u679c\u5b58\u5230MySQL\u770b\u4e0d\u5230\u5b9e\u65f6\u573a\u666f \u53ca\u65f6\u66f4\u65b0, \u5feb\u901f\u53cd\u9988<\/code><\/pre>\n<h3>3\u3001\u4f7f\u7528<\/h3>\n<h4>1.SET\uff1a\u6dfb\u52a0\u6570\u636e<\/h4>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; set name \u5c0f\u6b66\nOK<\/code><\/pre>\n<h4>2.GET\uff1a\u67e5\u770b\u6570\u636e<\/h4>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; get name\n\u5c0f\u6b66<\/code><\/pre>\n<h4>3.SET\uff1a\u4fee\u6539\u6570\u636e<\/h4>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; set name \u6b66\u5c0f\u8881\nOK\n127.0.0.1:6379&gt; get name\n\u6b66\u5c0f\u8881<\/code><\/pre>\n<h4>4.DEL\uff1a\u5220\u9664<\/h4>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; del name\n1\n127.0.0.1:6379&gt; get name\n<\/code><\/pre>\n<h4>5.EXISTS\uff1a\u5224\u65ad\u4e00\u4e2akey\u662f\u5426\u5b58\u5728<\/h4>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; EXISTS name\n0\n127.0.0.1:6379&gt; set name \u6b66\u5c0f\u8881\nOK\n127.0.0.1:6379&gt; EXISTS name\n1<\/code><\/pre>\n<h4>6.\u8fc7\u671f\u65f6\u95f4<\/h4>\n<h5>1\uff09TTL\uff1a\u67e5\u770b\u8fc7\u671f\u65f6\u95f4<\/h5>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; TTL name\n-1      # \u6c38\u4e45\u4e0d\u8fc7\u671f\n127.0.0.1:6379&gt; TTL name\n-2      # \u5df2\u7ecf\u8fc7\u671f\u4e86\n127.0.0.1:6379&gt; TTL name\n5       # \u5269\u4e0b5\u79d2\u949f\u5c31\u8fc7\u671f\u4e86<\/code><\/pre>\n<h5>2\uff09SETEX\uff1a\u8bbe\u7f6e\u4e00\u4e2a\u5355\u4f4d\u4ee5\u79d2\u7684\u8fc7\u671f\u7684\u6570\u636e<\/h5>\n<blockquote>\n<p>\u8bbe\u7f6e\u4e00\u4e2aname xiaowu\u8fc7\u671f\u65f6\u95f410\u79d2<\/p>\n<\/blockquote>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; set name xiaowu ex 10\n# \u7b49\u4ef7\u4e8e\n127.0.0.1:6379&gt; setex name 10 xiaowu<\/code><\/pre>\n<h5>3\uff09PSETEX\uff1a\u8bbe\u7f6e\u4e00\u4e2a\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\u7684\u8fc7\u671f\u65f6\u95f4<\/h5>\n<blockquote>\n<p>\u8bbe\u7f6e\u4e00\u4e2aname xiaowu\u8fc7\u671f\u65f6\u95f410000\u6beb\u79d2<\/p>\n<\/blockquote>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; set name xiaowu px 10000\n# \u7b49\u4ef7\u4e8e\n127.0.0.1:6379&gt; PSETEX name 10000 xiaowu<\/code><\/pre>\n<h4>7.key\u5b58\u5728\u6027\u5224\u65ad<\/h4>\n<h5>1\uff09SETNX\uff1a\u4e00\u4e2akey\u4e0d\u5b58\u5728\u5219\u521b\u5efa\uff0c\u5b58\u5728\u5219\u5ffd\u7565<\/h5>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; del name\n0\n127.0.0.1:6379&gt; set name xiaowu nx\nOK\n127.0.0.1:6379&gt; get name\nxiaowu\n127.0.0.1:6379&gt; set name wuxiaoyuan nx\n\n127.0.0.1:6379&gt; get name\nxiaowu\n# \u7b49\u4ef7\u4e8e\n127.0.0.1:6379&gt; del name\n1\n127.0.0.1:6379&gt; SETNX name xiaowu\n1\n127.0.0.1:6379&gt; get name\nxiaowu\n127.0.0.1:6379&gt; SETNX name wuxiaoyuan\n0\n127.0.0.1:6379&gt; get name\nxiaowu<\/code><\/pre>\n<h5>2\uff09SET [key] [value] xx\uff1a\u4e00\u4e2akey\u5b58\u5728\u5219\u66f4\u65b0\uff0c\u4e0d\u5b58\u5728\u5219\u5ffd\u7565<\/h5>\n<pre><code class=\"language-bash\"># \u6709\u5219\u66f4\u65b0\n127.0.0.1:6379&gt; set name xiaowu\nOK\n127.0.0.1:6379&gt; set name wuxiaoyuan xx\nOK\n127.0.0.1:6379&gt; get name\nwuxiaoyuan\n\n# \u65e0\u5219\u8df3\u8fc7\n127.0.0.1:6379&gt; del name\n1\n127.0.0.1:6379&gt; get name\n\n127.0.0.1:6379&gt; set name wuxiaoyuan xx\n\n127.0.0.1:6379&gt; get name\n\n127.0.0.1:6379&gt; <\/code><\/pre>\n<h4>8.MSET\uff1a\u8bbe\u7f6e\u591a\u4e2a\u503c<\/h4>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; MSET a 1 b 2 c 3\nOK\n127.0.0.1:6379&gt; KEYS *           #\u751f\u4ea7\u4e0a\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u5bb9\u6613\u9020\u6210\u5b95\u673a\nb\na\nc\n127.0.0.1:6379&gt; get a\n1\n127.0.0.1:6379&gt; get b\n2\n127.0.0.1:6379&gt; get c\n3<\/code><\/pre>\n<h4>9.GETSET\uff1a\u67e5\u770b\u539fvalue\u5e76\u66f4\u65b0value<\/h4>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; set name xiaowu\nOK\n127.0.0.1:6379&gt; GETSET name wuxiaoyuan\nxiaowu\n127.0.0.1:6379&gt; get name\nwuxiaoyuan<\/code><\/pre>\n<h4>10.SETRANGE\uff1a\u6309\u7167\u4e0b\u6807\u53bb\u66f4\u65b0<\/h4>\n<pre><code class=\"language-bash\">127.0.0.1:6379&gt; get name\nwuxiaoyuan\n127.0.0.1:6379&gt; SETRANGE name 2 111\n# \u4ece\u7b2c\u4e8c\u4e2a\u5b57\u7b26\u5f00\u59cb\u5411\u540e\u8986\u76d6111\n10\n127.0.0.1:6379&gt; get name\nwu111oyuan<\/code><\/pre>\n<h4>11.\u83b7\u53d6\u591a\u4e2akey\u503c<\/h4>\n<p><\/p><div id=\"rml_readmorelogin_placeholder\" style=\"position:relative;\"><div id=\"rml_fade_content\" style=\"position: absolute;\r\ntop:-10em;\r\nwidth:100%;\r\nheight:10em;\r\nbackground: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\"><\/div><div class=\"wpf-controller aru_rml_from_in_post\" style=\"background-color:#eeeeee;border:5px solid #cce6ff;\" id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><h2 id=\"Header\">\u67e5\u770b\u66f4\u591a<\/h2><div id=\"Message\"><p>\u8054\u7cfb\u7ba1\u7406\u5458\u5fae\u4fe1tutu19192010\uff0c\u6ce8\u518c\u8d26\u53f7<\/p>\n<\/div><div id=\"StatusBarHeader\"><\/div><form id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><input name=\"post_id\" value=\"1256\" type=\"hidden\"\/><input name=\"_init_callback\" value=\"InitLogin\" type=\"hidden\"\/><input name=\"post_id\" value=\"1256\" type=\"hidden\"\/><input name=\"rt_ype\" value=\"1\" type=\"hidden\"\/><input name=\"nonce\" value=\"3a0e71e360\" type=\"hidden\"\/><input name=\"_wpnonce\" value=\"fe0b6c877b\" type=\"hidden\"\/><input name=\"_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_proxy_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_view\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginView\" type=\"hidden\"\/><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\" width=\"400px\"><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Username:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"username\" value=\"\" type=\"text\"\/><\/td><\/tr><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Password:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"password\" value=\"\" type=\"password\"\/><\/td><\/tr><\/tbody><\/table><p class=\"wpf-table-placeholder submit\"><button class=\"wp_plugin_framework_ajax_button\" type=\"button\" style=\"background-color:#4D90FE;;color:#ffffff;;border:1px solid #3079ed;\" name=\"_event\" value=\"ButtonLogin\">Log in<\/button><\/p><\/td><td class=\"wpf-table-placeholder-input\"><\/td><\/tr><\/tbody><\/table><\/form><div id=\"ButtonStartRegister\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=register\">Register<\/a><\/div><div id=\"Link1\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=lostpassword\">Forgotten username or password?<\/a><\/div><div id=\"StatusBarFooter\"><\/div><\/div><\/div><div id=aru_remaining_content><\/div>","protected":false},"excerpt":{"rendered":"<p>\u767b\u5f55\u89c4\u8303 redis-cli -h IP -p PORT &#8211;raw -h # \u4e3b\u673aIP -p # \u7aef\u53e3 &#8212; [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[21,19,159,22,160,20],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1256"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1256"}],"version-history":[{"count":1,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1256\/revisions"}],"predecessor-version":[{"id":9939,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1256\/revisions\/9939"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}