{"id":1027,"date":"2023-04-25T16:37:20","date_gmt":"2023-04-25T08:37:20","guid":{"rendered":"https:\/\/white-night.club\/?p=1027"},"modified":"2023-11-09T11:07:56","modified_gmt":"2023-11-09T03:07:56","slug":"db1","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/04\/25\/db1\/","title":{"rendered":"Redis\u6570\u636e\u7c7b\u578b&#8211;String\uff08\u4e00\uff09"},"content":{"rendered":"\n<p>\u5b57\u7b26\u4e32\u7c7b\u578bString\u662fRedis\u4e2d\u6700\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u53ef\u4ee5\u5b58\u50a8\u5f88\u591a\u5185\u5bb9\uff0c\u5176\u4e2d\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul>\n<li>\u6570\u5b57\u7b49\u4e8c\u8fdb\u5236\u6570\u636e<\/li>\n\n\n\n<li>\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e<\/li>\n\n\n\n<li>JSON\u5316\u7684\u5bf9\u8c61<\/li>\n\n\n\n<li>\u7ecf\u8fc7BASE64\u7f16\u7801\u540e\u7684\u56fe\u7247\u7b49<\/li>\n<\/ul>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u4e00\u4e2aString\u7c7b\u578b\u7684\u952e\u6700\u5927\u80fd\u5b58\u50a8512MB\u7684\u6570\u636e\u3002<\/mark><\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc7\u4e00\u7cfb\u5217\u547d\u4ee4\u6765\u5b66\u4e60String\u7c7b\u578b\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u4ec0\u4e48\u662f\u952e\u503c\u5bf9\uff1f\u4e3a\u4ec0\u4e48\u8981\u7528\u952e\u503c\u5bf9\uff1f<\/p>\n<cite><em>\u524d\u5bfc\u6982\u5ff5<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u7ec6\u8bf4\u4ee5\u4e0b\u4ec0\u4e48\u662f\u952e\u503c\u5bf9\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe\u7ed9\u4f60\u4e2a\u94fe\u8868\uff0c\u6211\u4eec\u8981\u83b7\u53d6\u8868\u4e2d\u67d0\u4e2a\u8282\u70b9\u5305\u542b\u7684\u6570\u636e\uff0c\u90a3\u4e48\u65b9\u6cd5\u5c31\u662f\u4ece\u5934\u5f00\u59cb\u904d\u5386\uff0c\u76f4\u5230\u627e\u5230\u8be5\u8282\u70b9\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u989d\u5916\u8bbe\u7f6e\u4e00\u4e2a\u201c\u952e\u201d\uff0c\u8ba9\u8fd9\u4e2a\u6807\u8bc6\u7b26\u548c\u8fd9\u4e2a\u8282\u70b9\u7ed1\u5b9a\uff0c\u90a3\u4e48\u6bcf\u6b21\u6211\u4eec\u8981\u53bb\u83b7\u53d6\u8be5\u8282\u70b9\u5305\u542b\u7684\u6570\u636e\u7684\u65f6\u5019\uff0c\u5c31\u53ea\u7528\u53bb\u8bbf\u95ee\u201c\u952e\u201d\u5373\u53ef\u3002\u5373\u5f62\u6210\u4e00\u4e2a<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u201dKey-Value\u201c<\/mark>\u7684\u6620\u5c04\u5173\u7cfb\u3002<\/p>\n\n\n\n<p>\u800c\u5728redis\u4e2d\uff0ckey\u5747\u4e3aString\u7c7b\u578b\uff0c\u5982\u679c\u6b64\u65f6\u7684value\u4e5f\u4e3aString\u7c7b\u578b\uff0c\u90a3\u4e48&#8221;Key-Value&#8221;\u5c31\u76f8\u5f53\u4e8e\u4e00\u4e2a\u952e\u503c\u5bf9\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u8bbe\u7f6e\u952e\u503c\u5bf9<\/p>\n<cite><em>SET\u547d\u4ee4<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5728redis\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7SET\u6307\u4ee4\u6765\u8bbe\u7f6e\u952e\u503c\u5bf9\uff0c\u5176\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>SET key value [NX | XX] [GET] [EX seconds | PX milliseconds |<br>EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]<\/em><\/strong><\/p>\n\n\n\n<ul>\n<li><strong><em>EX second<\/em><\/strong>s\uff1a\u7528\u4e8e\u8bbe\u7f6ekey\u7684\u8fc7\u671f\u65f6\u95f4\u4e3a\u591a\u5c11\u79d2\u3002<\/li>\n\n\n\n<li><strong><em>PX milliseconds\uff1a<\/em><\/strong>\u7528\u4e8e\u8bbe\u7f6ekey\u7684\u8fc7\u671f\u65f6\u95f4\u4e3a\u591a\u5c11\u6beb\u79d2\u3002<\/li>\n\n\n\n<li><strong><em>NX|XX<\/em><\/strong>\uff1a\u8868\u793a\u5f53key\u4e0d\u5b58\u5728\/\u5b58\u5728\u65f6\uff0cSET\u6307\u4ee4\u624d\u4f1a\u5bf9key\u8fdb\u884c\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5176\u5b83\u7684\u8bf7\u53c2\u8003\u8fd9\u7bc7\u6587\u7ae0\u300a<a href=\"https:\/\/white-night.club\/index.php\/2023\/04\/27\/translate1\/\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0086ff\" class=\"has-inline-color\">redis\u5b98\u7f51\u2013set\u6307\u4ee4\u7ffb\u8bd1<\/mark><\/a>\u300b\u3002\u6211\u4eec\u5728RedisInsight\u4e2d\u8f93\u5165\u51e0\u6761SET\u6307\u4ee4\u6d4b\u8bd5\u4e00\u4e0b\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u7528RedisInsight\u4e3b\u8981\u662f\u53ef\u89c6\u5316\u5de5\u5177\u7528\u8d77\u6765\u6bd4\u8f83\u76f4\u89c2\u3002RedisInsight=\u547d\u4ee4\u884c+\u56fe\u5f62\u5316\u754c\u9762\u5b9e\u5728\u662f\u592a\u9999\u4e86\u3002<\/cite><\/blockquote>\n\n\n\n<p>\u5982\u679c\u4e0d\u5b58\u5728\u4e00\u4e2a\u540d\u4e3asztuname\u7684\u952e\uff0c\u5219\u65b0\u5efa\u4e00\u4e2a\u540d\u4e3asztuname\u7684\u952e\uff0c\u5c06\u5176\u503c\u8bbe\u4e3a&#8217;whitenight&#8217;\uff0c\u5e76\u5c06\u8be5\u952e\u7684\u8fc7\u671f\u65f6\u95f4\u8bbe\u7f6e\u4e3a1000\u79d2\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt; SET sztuname 'whitenight' EX 1000 NX\n\"OK\" <mark style=\"background-color:rgba(0, 0, 0, 0);color:#00ff2f\" class=\"has-inline-color\">\/\/\u8fd4\u56de\"OK\"\u8bf4\u660e\u6267\u884c\u6210\u529f<\/mark><\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u5b58\u5728sztuname\u8fd9\u4e2a\u952e\uff0c\u5c06\u5176\u503c\u6539\u4e3a&#8217;WhiteNight&#8217;\u5e76\u5c06\u8fc7\u671f\u65f6\u95f4\u8bbe\u7f6e\u4e3a100000\u6beb\u79d2\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt; SET sztuname 'WhiteNight' PX 100000 XX\n\"OK\"<\/code><\/pre>\n\n\n\n<p>\u987a\u5e26\u4e00\u63d0<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">EX\u548cPX\u53c2\u6570\u4e0d\u80fd\u540c\u65f6\u4f7f\u7528<\/mark>\uff0c\u53ea\u80fd\u4e24\u8005\u53d6\u5176\u4e00\u3002<\/p>\n\n\n\n<p>\u53ef\u89c6\u5316\u5de5\u5177\u597d\u5904\u5c31\u5728\u4e8e\u4f60\u4e0d\u7528\u8f93\u67e5\u8be2\u6307\u4ee4\u5c31\u80fd\u770b\u5230\u521a\u521a\u8bbe\u7f6e\u7684\u952e\u503c\u5bf9\u3002\u521a\u521aSET\u6307\u4ee4\u7684\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"474\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/04\/6ccb9a9ff657f9b1ff623d94b179a47-1024x474.png\" alt=\"\" class=\"wp-image-1045\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/04\/6ccb9a9ff657f9b1ff623d94b179a47-1024x474.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/04\/6ccb9a9ff657f9b1ff623d94b179a47-300x139.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/04\/6ccb9a9ff657f9b1ff623d94b179a47-768x355.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/04\/6ccb9a9ff657f9b1ff623d94b179a47-1536x710.png 1536w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/04\/6ccb9a9ff657f9b1ff623d94b179a47.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-background-color\">RedisInsight\u754c\u9762<\/mark><\/em><\/figcaption><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u4e3a\u4e86\u4fdd\u6301\u6587\u7ae0\u7684\u6574\u4f53\u683c\u5f0f\uff0c\u6545\u6ca1\u6709\u5bf9\u56fe\u7247\u7684\u5927\u5c0f\u4f5c\u51fa\u8c03\u6574\uff0c\u770b\u4e0d\u6e05\u56fe\u7247\u53ef\u4ee5CTRL+\u9f20\u6807\u6eda\u8f6e\u3002<\/cite><\/blockquote>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u8bbe\u7f6e\u591a\u4e2a\u952e\u503c\u5bf9<\/p>\n<cite><em>MSET\u547d\u4ee4<\/em><\/cite><\/blockquote>\n\n\n\n<p>MSET\u7684\u683c\u5f0f\u5982\u4e0b<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>MSET key value [key value \u2026]<\/em><\/strong><\/p>\n\n\n\n<p>\u548cSET\u4e00\u6837\uff0c\u5982\u679ckey\u5df2\u7ecf\u5b58\u5728\uff0c\u90a3\u4e48MSET\u4f1a\u7528\u65b0\u503c\u8986\u76d6\u65e7\u503c\u3002\u5176\u4ed6\u6ca1\u5565\u597d\u8bf4\u7684\uff0c\u76f4\u63a5\u4e3e\u4f8b\u5b50\u5c31\u660e\u767d\u4e86\u3002<\/p>\n\n\n\n<p>\u8bbe\u7f6ekey1\u548ckey2\u4e24\u4e2a\u952e\u503c\u5bf9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> MSET key1 \"This is key1\" key2 \"This is key2\"\r\n\"OK\"<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p class=\"has-luminous-vivid-amber-color has-text-color\">SETNX(deprecated)\/SETEX(Deprecated)\/MSETNX<\/p>\n<cite>\u524d\u4e24\u4e2a<em>\u53ef\u88abSET [OPTION]\u66ff\u4ee3<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u524d\u4e24\u6761\u6307\u4ee4\u90fd\u80fd\u88ab\u201dSET+\u9009\u9879\u201c\u66ff\u4ee3\uff0c\u66f4\u4f55\u51b5redis\u73b0\u5728\u5df2\u7ecf\u5f03\u7528\u4e86\u8fd9\u4e24\u6761\u6307\u4ee4\u3002\u6240\u4ee5\u76f4\u63a5\u628a\u8fd9\u4e9b\u653e\u4e00\u8d77\u8bb2\u4e86\u3002<\/p>\n\n\n\n<p>\u6bd4\u8f83\u7b80\u5355\uff0c\u76f4\u63a5\u4e0a\u4f8b\u5b50\uff0c\u8fd4\u56de1\u8bf4\u660e\u6267\u884c\u6210\u529f\uff0c\u8fd4\u56de0\u8bf4\u660e\u6267\u884c\u5931\u8d25\u3002\u8fd9\u610f\u5473\u7740\u4e2d\u4f7f\u7528\u201cMSETNX\u201d\u8fd9\u6761\u6307\u4ee4\u65f6\uff0c\u53ea\u8981\u5df2\u7ecf\u5b58\u5728\u67d0\u4e2akey\uff0cMSETNX\u5c31\u4e0d\u4f1a\u6267\u884c\u64cd\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> SETNX key3 \"None\"\r\n(integer) 1\r\n\r\n> MSETNX key3 \"This is key3\" key4 \"This is key4\"\r\n(integer) 0<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bbe\u7f6e\u952e\u503c\u5bf9<\/p>\n","protected":false},"author":1,"featured_media":1045,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[45,35],"tags":[39],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1027"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=1027"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1027\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/1045"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=1027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=1027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=1027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}