{"id":1254,"date":"2023-05-06T23:10:27","date_gmt":"2023-05-06T15:10:27","guid":{"rendered":"https:\/\/white-night.club\/?p=1254"},"modified":"2023-11-09T11:07:55","modified_gmt":"2023-11-09T03:07:55","slug":"db2","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/05\/06\/db2\/","title":{"rendered":"Redis\u6570\u636e\u7c7b\u578b\u2013String\uff08\u4e8c\uff09"},"content":{"rendered":"\n<p>\u4e0a\u4e00\u8282\u63d0\u5230\u4e86\u5982\u4f55\u8bbe\u7f6e\u952e\u503c\u5bf9\u3002\u90a3\u4e48\u63a5\u4e0b\u6765\u5c31\u662f\u5982\u4f55\u83b7\u53d6\u952e\u503c\u5bf9\u4e86\u3002\u4e0d\u8fc7GETRANGE\u6682\u65f6\u6ca1\u611f\u89c9\u5230\u5b9e\u9645\u7528\u9014\u5728\u54ea\uff0c\u4ee5\u540e\u7528\u5230\u4e86\u518d\u5199\u8fdb\u6765\u5427\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>\u83b7\u53d6\u952e\u503c\u5bf9<\/p>\n<cite><em>GET\uff0cMGET<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u683c\u5f0f\u5f88\u7b80\u5355\uff0c\u653e\u4e00\u8d77\u8bb2\u4e86\u3002\u683c\u5f0f\u5982\u4e0b<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>GET key<br>MGET key [key &#8230;]<\/em><\/strong><\/p>\n\n\n\n<p>\u4e24\u8005\u5982\u679c\u6ca1\u627e\u5230\u5bf9\u5e94\u7684key\uff0c\u8fd4\u56de\u7684\u90fd\u662fnil\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u627e\u5230\u4e86\uff0cGET\u8fd4\u56de\u952e\u7684\u503c\uff0cMGET\u5219\u662f\u8fd4\u56de\u4e00\u4e2a\u6570\u7ec4\u3002<\/p>\n\n\n\n<p>\u76f4\u63a5\u6765\u770b\u4f8b\u5b50\uff0c\u7528\u7684\u8fd8\u662fRedisInsight\uff0c\u61d2\u5f97\u622a\u56fe\u4e86\uff0c\u76f4\u63a5\u653e\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> MSETNX key1 \"data1\" key2 \"data2\"\r\n(integer) 1\n\n> GET key1\n\"data1\"\n\n> MGET key1 key2 key3\n1) \"data1\"\n2) \"data2\"\n3) \"null\"<\/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-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>GETEX\u548cGETDEL\u662f6.2.0\u624d\u52a0\u5165\u7684\u65b0\u6307\u4ee4\u3002\u6211Windows\u4e0a\u7528\u7684\u8fd8\u662f3.\u51e0\u7684\u7248\u672c\uff0c\u6240\u4ee5\u8f93\u5165GETEX\u4f1a\u63d0\u793a&#8221;ERR unknown command &#8216;GETEX'&#8221;\u3002\u6240\u4ee5\u540e\u7eed\u90fd\u662f\u5728Redis\u5b98\u7f51\u4e0a\u8f93\u5165\u7684\u3002<\/cite><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>GETEX<\/p>\n<cite><em>\u53ef\u8bbe\u7f6e\u952e\u7684TTL<\/em><\/cite><\/blockquote>\n\n\n\n<p>GETEX\u7684\u683c\u5f0f\u548cGET\u4e0d\u592a\u4e00\u6837\uff0c\u5b83\u6709\u7740\u548cSET\u6307\u4ee4\u7c7b\u4f3c\u7684options\u3002\u683c\u5f0f\u5982\u4e0b<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>GETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds |PXAT unix-time-milliseconds | PERSIST]<\/em><\/strong><\/p>\n\n\n\n<p>\u5176\u4e2d<strong><em>PERSIST<\/em><\/strong>\u6307\u7684\u662f\u201c\u79fb\u9664\u952e\u539f\u672c\u7684TTL\u201c\u3002\u5177\u4f53\u7528\u6cd5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>redis> SET key \"data\" EX 10000\n\"OK\"\nredis> TTL key\n(integer) 9994\nredis> GET key\n\"data\"\nredis> GETEX key PERSIST\n\"data\"\nredis> TTL key\n(integer) -1\n<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230<strong><em>PERSIST<\/em><\/strong>\u76f4\u63a5\u79fb\u9664\u4e86\u952e\u7684TTL\u3002\uff08-1\u8868\u793a\u6ca1\u6709TTL\uff09\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u7528GETEX\u518d\u8bbe\u7f6e\u56de\u53bb\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>redis> GETEX key EX 10000\r\n\"data\"\r\nredis> TTL key\r\n(integer) 9996<\/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>GETDEL<\/p>\n<cite><em>\u83b7\u53d6\u952e\u503c\u5e76\u5220\u9664\u952e<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\u53ea\u6709\u952e\u503c\u4e3aString\u7c7b\u578b\u65f6GETDEL\u624d\u4f1a\u5220\u9664\u952e\uff0c\u4e0d\u7136\u4f1a\u62a5\u9519\u3002\u5176\u683c\u5f0f\u548c\u4f7f\u7528\u4f8b\u5982\u4e0b<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>GETDEL key<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>redis> SET key \"data\"\r\n\"OK\"\r\nredis> GET key\r\n\"data\"\r\nredis> GETDEL key\r\n\"data\"\r\nredis> GET key\r\n(nil)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>GET\uff0cMGET\uff0cGETEX\uff0cGETDEL<\/p>\n","protected":false},"author":1,"featured_media":3123,"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\/1254"}],"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=1254"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1254\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/3123"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=1254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=1254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=1254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}