{"id":5070,"date":"2024-11-14T12:41:51","date_gmt":"2024-11-14T04:41:51","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5070\/"},"modified":"2024-11-14T12:41:51","modified_gmt":"2024-11-14T04:41:51","slug":"redis%e6%80%8e%e4%b9%88%e5%ba%8f%e5%88%97%e5%8c%96","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5070\/","title":{"rendered":"redis\u600e\u4e48\u5e8f\u5217\u5316"},"content":{"rendered":"<blockquote><p>\n  redis\u6839\u636e\u6570\u636e\u7c7b\u578b\u81ea\u52a8\u9009\u62e9\u4e0d\u540c\u7684\u5e8f\u5217\u5316\u65b9\u5f0f\uff1a\u5b57\u7b26\u4e32\u6570\u636e\u7c7b\u578b\uff1aresp\uff08\u6587\u672c\u534f\u8bae\uff09\u54c8\u5e0c\u6570\u636e\u7c7b\u578b\uff1ardb\uff08\u4e8c\u8fdb\u5236\u683c\u5f0f\uff09\u4f4d\u56fe\u548c\u6709\u5e8f\u96c6\u5408\u6570\u636e\u7c7b\u578b\uff1asds\uff08\u4e8c\u8fdb\u5236\u683c\u5f0f\uff09geo\u6570\u636e\u7c7b\u578b\uff1ageo\u5e8f\u5217\u5316\u5668stream\u6570\u636e\u7c7b\u578b\uff1astream\u5e8f\u5217\u5316\u5668\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/21\/2024052114091747912.jpg\" class=\"aligncenter\" title=\"redis\u600e\u4e48\u5e8f\u5217\u5316\u63d2\u56fe\" alt=\"redis\u600e\u4e48\u5e8f\u5217\u5316\u63d2\u56fe\" \/><\/p>\n<h2>Redis\u4e2d\u7684\u5e8f\u5217\u5316<\/h2>\n<p><strong>\u5e8f\u5217\u5316<\/strong>\u662f\u6307\u5c06\u5bf9\u8c61\u8f6c\u6362\u4e3a\u53ef\u4ee5\u5b58\u50a8\u6216\u4f20\u8f93\u7684\u5b57\u8282\u5e8f\u5217\u7684\u8fc7\u7a0b\u3002Redis\u4f7f\u7528\u4e0d\u540c\u7c7b\u578b\u7684\u5e8f\u5217\u5316\u5668\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u5e8f\u5217\u5316\uff0c\u8fd9\u53d6\u51b3\u4e8e\u5b58\u50a8\u7684\u6570\u636e\u7c7b\u578b\uff1a<\/p>\n<h3>\u5b57\u7b26\u4e32\u6570\u636e\u7c7b\u578b<\/h3>\n<ul>\n<li> <strong>RESP (REdis Serialization Protocol)<\/strong>\uff1a\u5b57\u7b26\u4e32\u3001\u5217\u8868\u548c\u96c6\u5408\u7b49\u5b57\u7b26\u4e32\u6570\u636e\u7c7b\u578b\u4f7f\u7528RESP \u8fdb\u884c\u5e8f\u5217\u5316\u3002RESP\u662f\u4e00\u79cd\u7b80\u5355\u7684\u6587\u672c\u534f\u8bae\uff0c\u4f7f\u7528\u661f\u53f7\u3001\u7f8e\u5143\u7b26\u53f7\u548c\u6362\u884c\u7b26\u6765\u8868\u793a\u5bf9\u8c61\u3002<\/li>\n<\/ul>\n<h3>\u54c8\u5e0c\u6570\u636e\u7c7b\u578b<\/h3>\n<ul>\n<li> <strong>RDB (Redis Database)<\/strong>\uff1a\u54c8\u5e0c\u7c7b\u578b\u4f7f\u7528RDB\u8fdb\u884c\u5e8f\u5217\u5316\u3002RDB\u662f\u4e00\u79cd\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u5b83\u5c06\u5bf9\u8c61\u5b58\u50a8\u4e3a\u4e00\u7cfb\u5217\u3002<\/li>\n<\/ul>\n<h3>\u4f4d\u56fe\u548c\u6709\u5e8f\u96c6\u5408\u6570\u636e\u7c7b\u578b<\/h3>\n<ul>\n<li> <strong>SDS (Simple Dynamic String)<\/strong>\uff1a\u4f4d\u56fe\u548c\u6709\u5e8f\u96c6\u5408\u6570\u636e\u7c7b\u578b\u4f7f\u7528SDS\u8fdb\u884c\u5e8f\u5217\u5316\u3002SDS\u662f\u4e00\u79cd\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u5b83\u5c06\u5b57\u7b26\u4e32\u8868\u793a\u4e3a\u4e00\u7cfb\u5217\u5b57\u8282\u5757\uff0c\u6bcf\u4e2a\u5757\u90fd\u6709\u81ea\u5df1\u7684\u957f\u5ea6\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<h3>\u5176\u4ed6\u6570\u636e\u7c7b\u578b<\/h3>\n<ul>\n<li> <strong>GEO (Geographical)<\/strong>\uff1aGEO\u6570\u636e\u7c7b\u578b\u4f7f\u7528\u4e13\u7528\u7684GEO \u5e8f\u5217\u5316\u5668\u8fdb\u884c\u5e8f\u5217\u5316\u3002<\/li>\n<li> <strong>STREAM (\u65f6\u95f4\u5e8f\u5217)<\/strong>\uff1aSTREAM\u6570\u636e\u7c7b\u578b\u4f7f\u7528\u4e13\u7528\u7684STREAM \u5e8f\u5217\u5316\u5668\u8fdb\u884c\u5e8f\u5217\u5316\u3002<\/li>\n<\/ul>\n<p><strong>\u9009\u62e9\u5e8f\u5217\u5316\u5668<\/strong><\/p>\n<p>Redis\u4f1a\u6839\u636e\u6570\u636e\u7c7b\u578b\u7684\u4e0d\u540c\u81ea\u52a8\u9009\u62e9\u9002\u5f53\u7684\u5e8f\u5217\u5316\u5668\u3002\u4f46\u662f\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u624b\u52a8\u6307\u5b9a\u5e8f\u5217\u5316\u5668\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u9700\u8981\u4ee5\u4e8c\u8fdb\u5236\u683c\u5f0f\u5b58\u50a8\u5b57\u7b26\u4e32\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528REDIS_RDB \u5e8f\u5217\u5316\u5668\u3002<\/p>\n<pre>SET my_string BINARY my_binary_data REDIS_RDB<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u81ea\u5b9a\u4e49\u5e8f\u5217\u5316\u5668<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u9700\u8981\u4f7f\u7528\u81ea\u5b9a\u4e49\u5e8f\u5217\u5316\u5668\uff0cRedis\u5141\u8bb8\u60a8\u6ce8\u518c\u548c\u4f7f\u7528\u5b83\u4eec\u3002\u8981\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605Redis\u6587\u6863\u4e2d\u7684REDIS_SERIALIZER_REGISTER_FN\u548cREDIS_SERIALIZER_FN\u51fd\u6570\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5e8f\u5217\u5316\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>redis\u6839\u636e\u6570\u636e\u7c7b\u578b\u81ea\u52a8\u9009\u62e9\u4e0d\u540c\u7684\u5e8f\u5217\u5316\u65b9\u5f0f\uff1a\u5b57\u7b26\u4e32\u6570\u636e\u7c7b\u578b\uff1aresp\uff08\u6587\u672c\u534f\u8bae\uff09\u54c8\u5e0c\u6570\u636e\u7c7b\u578b\uff1ardb\uff08\u4e8c\u8fdb\u5236\u683c\u5f0f\uff09\u4f4d\u56fe\u548c\u6709\u5e8f\u96c6\u5408\u6570\u636e\u7c7b\u578b\uff1asds\uff08\u4e8c\u8fdb\u5236\u683c\u5f0f\uff09geo\u6570\u636e\u7c7b\u578b\uff1ageo\u5e8f\u5217\u5316\u5668stream\u6570\u636e\u7c7b\u578b\uff1astream\u5e8f\u5217\u5316\u5668 Redis\u4e2d\u7684\u5e8f\u5217\u5316 \u5e8f\u5217\u5316\u662f\u6307\u5c06\u5bf9\u8c61\u8f6c\u6362\u4e3a\u53ef\u4ee5\u5b58\u50a8\u6216\u4f20\u8f93\u7684\u5b57\u8282\u5e8f\u5217\u7684\u8fc7\u7a0b\u3002Redis\u4f7f\u7528\u4e0d\u540c\u7c7b\u578b\u7684\u5e8f\u5217\u5316\u5668\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u5e8f\u5217\u5316\uff0c\u8fd9\u53d6\u51b3\u4e8e\u5b58\u50a8\u7684\u6570\u636e\u7c7b\u578b\uff1a \u5b57\u7b26\u4e32\u6570\u636e\u7c7b\u578b RESP (REdis Serialization Protocol)\uff1a\u5b57\u7b26\u4e32\u3001\u5217\u8868\u548c\u96c6\u5408\u7b49\u5b57\u7b26\u4e32\u6570\u636e\u7c7b\u578b\u4f7f\u7528RESP \u8fdb\u884c\u5e8f\u5217\u5316\u3002RESP\u662f\u4e00\u79cd\u7b80\u5355\u7684\u6587\u672c\u534f\u8bae\uff0c\u4f7f\u7528\u661f\u53f7\u3001\u7f8e\u5143\u7b26\u53f7\u548c\u6362\u884c\u7b26\u6765\u8868\u793a\u5bf9\u8c61\u3002 \u54c8\u5e0c\u6570\u636e\u7c7b\u578b RDB (Redis Database)\uff1a\u54c8\u5e0c\u7c7b\u578b\u4f7f\u7528RDB\u8fdb\u884c\u5e8f\u5217\u5316\u3002RDB\u662f\u4e00\u79cd\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u5b83\u5c06\u5bf9\u8c61\u5b58\u50a8\u4e3a\u4e00\u7cfb\u5217\u3002 \u4f4d\u56fe\u548c\u6709\u5e8f\u96c6\u5408\u6570\u636e\u7c7b\u578b SDS (Simple Dynamic String)\uff1a\u4f4d\u56fe\u548c\u6709\u5e8f\u96c6\u5408\u6570\u636e\u7c7b\u578b\u4f7f\u7528SDS\u8fdb\u884c\u5e8f\u5217\u5316\u3002SDS\u662f\u4e00\u79cd\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u5b83\u5c06\u5b57\u7b26\u4e32\u8868\u793a\u4e3a\u4e00\u7cfb\u5217\u5b57\u8282\u5757\uff0c\u6bcf\u4e2a\u5757\u90fd\u6709\u81ea\u5df1\u7684\u957f\u5ea6\u4fe1\u606f\u3002 \u5176\u4ed6\u6570\u636e\u7c7b\u578b GEO (Geographical)\uff1aGEO\u6570\u636e\u7c7b\u578b\u4f7f\u7528\u4e13\u7528\u7684GEO \u5e8f\u5217\u5316\u5668\u8fdb\u884c\u5e8f\u5217\u5316\u3002 STREAM (\u65f6\u95f4\u5e8f\u5217)\uff1aSTREAM\u6570\u636e\u7c7b\u578b\u4f7f\u7528\u4e13\u7528\u7684STREAM \u5e8f\u5217\u5316\u5668\u8fdb\u884c\u5e8f\u5217\u5316\u3002 \u9009\u62e9\u5e8f\u5217\u5316\u5668 Redis\u4f1a\u6839\u636e\u6570\u636e\u7c7b\u578b\u7684\u4e0d\u540c\u81ea\u52a8\u9009\u62e9\u9002\u5f53\u7684\u5e8f\u5217\u5316\u5668\u3002\u4f46\u662f\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u624b\u52a8\u6307\u5b9a\u5e8f\u5217\u5316\u5668\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u9700\u8981\u4ee5\u4e8c\u8fdb\u5236\u683c\u5f0f\u5b58\u50a8\u5b57\u7b26\u4e32\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528REDIS_RDB \u5e8f\u5217\u5316\u5668\u3002 SET my_string BINARY my_binary_data REDIS_RDB \u767b\u5f55\u540e\u590d\u5236 \u81ea\u5b9a\u4e49\u5e8f\u5217\u5316\u5668 \u5982\u679c\u60a8\u9700\u8981\u4f7f\u7528\u81ea\u5b9a\u4e49\u5e8f\u5217\u5316\u5668\uff0cRedis\u5141\u8bb8\u60a8\u6ce8\u518c\u548c\u4f7f\u7528\u5b83\u4eec\u3002\u8981\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605Redis\u6587\u6863\u4e2d\u7684REDIS_SERIALIZER_REGISTER_FN\u548cREDIS_SERIALIZER_FN\u51fd\u6570\u3002 \u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5e8f\u5217\u5316\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5070","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5070","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=5070"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5070\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}