{"id":185198,"date":"2024-11-10T19:33:17","date_gmt":"2024-11-10T11:33:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/185198\/"},"modified":"2024-11-10T19:33:18","modified_gmt":"2024-11-10T11:33:18","slug":"%e4%bd%bf%e7%94%a8redis%e8%bd%89%e6%8f%9bjson%e5%87%ba%e9%8c%af%ef%bc%88redis%e8%bd%89json%e5%87%ba%e9%8c%af%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/185198\/","title":{"rendered":"\u4f7f\u7528Redis\u8f49\u63dbJSON\u51fa\u932f\uff08redis\u8f49json\u51fa\u932f\uff09"},"content":{"rendered":"<h1 id=\"%e4%bd%bf%e7%94%a8redis%e8%bd%89%e6%8f%9bjson%e5%87%ba%e9%8c%af%ef%bc%88redis%e8%bd%89json%e5%87%ba%e9%8c%af%ef%bc%89-mudgKCrKSQ\">\u4f7f\u7528Redis\u8f49\u63dbJSON\u51fa\u932f\uff08redis\u8f49json\u51fa\u932f\uff09<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u61c9\u7528\u7a0b\u5f0f\u958b\u767c\u4e2d\uff0cRedis\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u9375\u503c\u5b58\u5132\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u6578\u64da\u7de9\u5b58\u548c\u5373\u6642\u6578\u64da\u8655\u7406\u3002\u7136\u800c\uff0c\u5728\u4f7f\u7528Redis\u9032\u884cJSON\u6578\u64da\u8f49\u63db\u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u9019\u4e9b\u932f\u8aa4\u7684\u539f\u56e0\u53ca\u5176\u89e3\u6c7a\u65b9\u6848\uff0c\u5e6b\u52a9\u958b\u767c\u8005\u66f4\u6709\u6548\u5730\u4f7f\u7528Redis\u3002<\/p>\n<h2 id=\"redis%e8%88%87json%e7%9a%84%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5-mudgKCrKSQ\">Redis\u8207JSON\u7684\u57fa\u672c\u6982\u5ff5<\/h2>\n<p>Redis\u662f\u4e00\u500b\u958b\u6e90\u7684\u5167\u5b58\u6578\u64da\u7d50\u69cb\u5b58\u5132\u7cfb\u7d71\uff0c\u652f\u6301\u591a\u7a2e\u6578\u64da\u7d50\u69cb\uff0c\u5982\u5b57\u7b26\u4e32\u3001\u54c8\u5e0c\u3001\u5217\u8868\u3001\u96c6\u5408\u7b49\u3002JSON\uff08JavaScript Object Notation\uff09\u662f\u4e00\u7a2e\u8f15\u91cf\u7d1a\u7684\u6578\u64da\u4ea4\u63db\u683c\u5f0f\uff0c\u6613\u65bc\u4eba\u985e\u95b1\u8b80\u548c\u7de8\u5beb\uff0c\u4e5f\u6613\u65bc\u6a5f\u5668\u89e3\u6790\u548c\u751f\u6210\u3002<\/p>\n<p>\u5728\u8a31\u591a\u61c9\u7528\u4e2d\uff0c\u958b\u767c\u8005\u9700\u8981\u5c07\u8907\u96dc\u7684\u6578\u64da\u7d50\u69cb\u5b58\u5132\u5230Redis\u4e2d\uff0c\u9019\u6642\u5019JSON\u683c\u5f0f\u5c31\u986f\u5f97\u5c24\u70ba\u91cd\u8981\u3002\u4f7f\u7528JSON\u683c\u5f0f\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c07\u6578\u64da\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\uff0c\u5f9e\u800c\u5728Redis\u4e2d\u9032\u884c\u5b58\u5132\u548c\u6aa2\u7d22\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e7%9a%84%e8%bd%89%e6%8f%9b%e9%8c%af%e8%aa%a4-mudgKCrKSQ\">\u5e38\u898b\u7684\u8f49\u63db\u932f\u8aa4<\/h2>\n<p>\u5728\u4f7f\u7528Redis\u9032\u884cJSON\u8f49\u63db\u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u4ee5\u4e0b\u5e7e\u7a2e\u5e38\u898b\u932f\u8aa4\uff1a<\/p>\n<ul>\n<li><strong>\u683c\u5f0f\u932f\u8aa4\uff1a<\/strong>\u7576JSON\u5b57\u7b26\u4e32\u7684\u683c\u5f0f\u4e0d\u6b63\u78ba\u6642\uff0cRedis\u5c07\u7121\u6cd5\u6b63\u78ba\u89e3\u6790\u3002\u4f8b\u5982\uff0c\u7f3a\u5c11\u9017\u865f\u3001\u5f15\u865f\u4e0d\u5339\u914d\u7b49\u90fd\u6703\u5c0e\u81f4\u683c\u5f0f\u932f\u8aa4\u3002<\/li>\n<li><strong>\u6578\u64da\u985e\u578b\u4e0d\u5339\u914d\uff1a<\/strong>Redis\u652f\u6301\u591a\u7a2e\u6578\u64da\u985e\u578b\uff0c\u82e5\u5617\u8a66\u5c07\u4e0d\u652f\u6301\u7684\u6578\u64da\u985e\u578b\u5b58\u5132\u70baJSON\uff0c\u5247\u6703\u51fa\u73fe\u932f\u8aa4\u3002<\/li>\n<li><strong>\u5b57\u7b26\u7de8\u78bc\u554f\u984c\uff1a<\/strong>\u5728\u8655\u7406\u5305\u542b\u7279\u6b8a\u5b57\u7b26\u7684JSON\u5b57\u7b26\u4e32\u6642\uff0c\u53ef\u80fd\u6703\u51fa\u73fe\u7de8\u78bc\u554f\u984c\uff0c\u5c0e\u81f4\u8f49\u63db\u5931\u6557\u3002<\/li>\n<\/ul>\n<h2 id=\"%e9%8c%af%e8%aa%a4%e7%a4%ba%e4%be%8b%e5%8f%8a%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-mudgKCrKSQ\">\u932f\u8aa4\u793a\u4f8b\u53ca\u89e3\u6c7a\u65b9\u6848<\/h2>\n<h3 id=\"1-%e6%a0%bc%e5%bc%8f%e9%8c%af%e8%aa%a4-mudgKCrKSQ\">1. \u683c\u5f0f\u932f\u8aa4<\/h3>\n<pre><code>{\n    \"name\": \"Server.HK\"\n    \"type\": \"VPS\"\n}<\/code><\/pre>\n<p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u7f3a\u5c11\u4e86&#8221;name&#8221;\u548c&#8221;type&#8221;\u4e4b\u9593\u7684\u9017\u865f\u3002\u6b63\u78ba\u7684\u683c\u5f0f\u61c9\u70ba\uff1a<\/p>\n<pre><code>{\n    \"name\": \"Server.HK\",\n    \"type\": \"VPS\"\n}<\/code><\/pre>\n<h3 id=\"2-%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b%e4%b8%8d%e5%8c%b9%e9%85%8d-mudgKCrKSQ\">2. \u6578\u64da\u985e\u578b\u4e0d\u5339\u914d<\/h3>\n<p>\u5047\u8a2d\u6211\u5011\u5617\u8a66\u5c07\u4e00\u500b\u6578\u5b57\u5b58\u5132\u70ba\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre><code>{\n    \"id\": \"12345\"\n}<\/code><\/pre>\n<p>\u5982\u679cRedis\u671f\u671b\u4e00\u500b\u6574\u6578\u985e\u578b\u7684\u503c\uff0c\u5247\u6703\u5c0e\u81f4\u932f\u8aa4\u3002\u89e3\u6c7a\u65b9\u6848\u662f\u78ba\u4fdd\u6578\u64da\u985e\u578b\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<h3 id=\"3-%e5%ad%97%e7%ac%a6%e7%b7%a8%e7%a2%bc%e5%95%8f%e9%a1%8c-mudgKCrKSQ\">3. \u5b57\u7b26\u7de8\u78bc\u554f\u984c<\/h3>\n<p>\u7576JSON\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u7279\u6b8a\u5b57\u7b26\uff08\u5982\u4e2d\u6587\u5b57\u7b26\uff09\u6642\uff0c\u53ef\u80fd\u6703\u51fa\u73fe\u7de8\u78bc\u554f\u984c\u3002\u78ba\u4fdd\u4f7f\u7528UTF-8\u7de8\u78bc\u4f86\u907f\u514d\u9019\u985e\u554f\u984c\u3002<\/p>\n<h2 id=\"%e6%9c%80%e4%bd%b3%e5%af%a6%e8%b8%90-mudgKCrKSQ\">\u6700\u4f73\u5be6\u8e10<\/h2>\n<p>\u70ba\u4e86\u907f\u514d\u5728\u4f7f\u7528Redis\u8f49\u63dbJSON\u6642\u51fa\u73fe\u932f\u8aa4\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u9075\u5faa\u4ee5\u4e0b\u6700\u4f73\u5be6\u8e10\uff1a<\/p>\n<ul>\n<li>\u59cb\u7d42\u6aa2\u67e5JSON\u5b57\u7b26\u4e32\u7684\u683c\u5f0f\uff0c\u4f7f\u7528\u5728\u7dda\u5de5\u5177\u6216\u5eab\u4f86\u9a57\u8b49\u5176\u6b63\u78ba\u6027\u3002<\/li>\n<li>\u78ba\u4fdd\u6578\u64da\u985e\u578b\u7684\u4e00\u81f4\u6027\uff0c\u907f\u514d\u5c07\u4e0d\u517c\u5bb9\u7684\u6578\u64da\u985e\u578b\u5b58\u5132\u5230Redis\u4e2d\u3002<\/li>\n<li>\u4f7f\u7528\u9069\u7576\u7684\u5b57\u7b26\u7de8\u78bc\uff0c\u7279\u5225\u662f\u5728\u8655\u7406\u591a\u8a9e\u8a00\u6578\u64da\u6642\u3002<\/li>\n<li>\u8003\u616e\u4f7f\u7528Redis\u7684JSON\u6a21\u7d44\uff08\u5982RedisJSON\uff09\uff0c\u9019\u6a23\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u8655\u7406JSON\u6578\u64da\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-mudgKCrKSQ\">\u7e3d\u7d50<\/h2>\n<p>\u5728\u4f7f\u7528Redis\u9032\u884cJSON\u8f49\u63db\u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u683c\u5f0f\u932f\u8aa4\u3001\u6578\u64da\u985e\u578b\u4e0d\u5339\u914d\u548c\u5b57\u7b26\u7de8\u78bc\u554f\u984c\u7b49\u6311\u6230\u3002\u901a\u904e\u9075\u5faa\u6700\u4f73\u5be6\u8e10\u548c\u4f7f\u7528\u5408\u9069\u7684\u5de5\u5177\uff0c\u9019\u4e9b\u554f\u984c\u662f\u53ef\u4ee5\u6709\u6548\u89e3\u6c7a\u7684\u3002\u82e5\u60a8\u9700\u8981\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u61c9\u7528\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528Redis\u8f49\u63dbJSON\u6642\u51fa\u73fe\u932f\u8aa4\uff1f\u4e86\u89e3\u5e38\u898b\u554f\u984c\u53ca\u89e3\u6c7a\u65b9\u6848\uff0c\u8f15\u9b06\u6392\u9664Redis\u8f49JSON\u7684\u6545\u969c\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-185198","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/185198","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"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=185198"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/185198\/revisions"}],"predecessor-version":[{"id":185199,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/185198\/revisions\/185199"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=185198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=185198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=185198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}