{"id":190720,"date":"2024-11-12T14:56:25","date_gmt":"2024-11-12T06:56:25","guid":{"rendered":"https:\/\/server.hk\/cnblog\/190720\/"},"modified":"2024-11-12T14:56:26","modified_gmt":"2024-11-12T06:56:26","slug":"%e7%89%a9%e8%81%af%e7%b6%b2%e7%99%bc%e5%b1%95%e8%93%ac%e5%8b%83%ef%bc%8credis%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a9%e5%8a%9b%e5%8a%a0%e9%80%9f%ef%bc%88redis%e7%89%a9%e8%81%af%e7%b6%b2%e6%95%b8%e6%93%9a","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/190720\/","title":{"rendered":"\u7269\u806f\u7db2\u767c\u5c55\u84ec\u52c3\uff0cRedis\u6578\u64da\u5eab\u52a9\u529b\u52a0\u901f\uff08redis\u7269\u806f\u7db2\u6578\u64da\u5eab\uff09"},"content":{"rendered":"<h1 id=\"%e7%89%a9%e8%81%af%e7%b6%b2%e7%99%bc%e5%b1%95%e8%93%ac%e5%8b%83%ef%bc%8credis%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a9%e5%8a%9b%e5%8a%a0%e9%80%9f-ZkpzzPJWgR\">\u7269\u806f\u7db2\u767c\u5c55\u84ec\u52c3\uff0cRedis\u6578\u64da\u5eab\u52a9\u529b\u52a0\u901f<\/h1>\n<p>\u96a8\u8457\u7269\u806f\u7db2\uff08IoT\uff09\u6280\u8853\u7684\u8fc5\u901f\u767c\u5c55\uff0c\u8d8a\u4f86\u8d8a\u591a\u7684\u8a2d\u5099\u548c\u61c9\u7528\u7a0b\u5e8f\u958b\u59cb\u9023\u63a5\u5230\u4e92\u806f\u7db2\uff0c\u5f62\u6210\u4e86\u4e00\u500b\u9f90\u5927\u7684\u6578\u64da\u751f\u614b\u7cfb\u7d71\u3002\u6839\u64da\u5e02\u5834\u7814\u7a76\u6a5f\u69cb\u7684\u5831\u544a\uff0c\u9810\u8a08\u52302025\u5e74\uff0c\u5168\u7403\u7269\u806f\u7db2\u8a2d\u5099\u7684\u6578\u91cf\u5c07\u9054\u5230750\u5104\u500b\u3002\u9019\u4e00\u589e\u9577\u5e36\u4f86\u4e86\u5de8\u5927\u7684\u6578\u64da\u6311\u6230\uff0c\u5982\u4f55\u9ad8\u6548\u5730\u5b58\u5132\u3001\u8655\u7406\u548c\u5206\u6790\u9019\u4e9b\u6578\u64da\u6210\u70ba\u4e86\u4f01\u696d\u9762\u81e8\u7684\u91cd\u8981\u8ab2\u984c\u3002\u5728\u9019\u500b\u80cc\u666f\u4e0b\uff0cRedis\u6578\u64da\u5eab\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\uff0c\u6b63\u9010\u6f38\u6210\u70ba\u7269\u806f\u7db2\u61c9\u7528\u7684\u9996\u9078\u3002<\/p>\n<h2 id=\"redis%e6%95%b8%e6%93%9a%e5%ba%ab%e6%a6%82%e8%bf%b0-ZkpzzPJWgR\">Redis\u6578\u64da\u5eab\u6982\u8ff0<\/h2>\n<p>Redis\u662f\u4e00\u7a2e\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\u548c\u6709\u5e8f\u96c6\u5408\u7b49\u3002\u7531\u65bc\u5176\u9ad8\u6027\u80fd\u548c\u9748\u6d3b\u6027\uff0cRedis\u88ab\u5ee3\u6cdb\u61c9\u7528\u65bc\u7de9\u5b58\u3001\u6d88\u606f\u968a\u5217\u548c\u5be6\u6642\u6578\u64da\u5206\u6790\u7b49\u5834\u666f\u3002\u5176\u4e3b\u8981\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u9ad8\u6027\u80fd\uff1a<\/strong>Redis\u80fd\u5920\u4ee5\u6beb\u79d2\u7d1a\u7684\u5ef6\u9072\u8655\u7406\u6578\u767e\u842c\u6b21\u8acb\u6c42\uff0c\u9019\u4f7f\u5f97\u5b83\u975e\u5e38\u9069\u5408\u9700\u8981\u5feb\u901f\u97ff\u61c9\u7684\u7269\u806f\u7db2\u61c9\u7528\u3002<\/li>\n<li><strong>\u6301\u4e45\u5316\uff1a<\/strong>\u96d6\u7136Redis\u4e3b\u8981\u662f\u5167\u5b58\u6578\u64da\u5eab\uff0c\u4f46\u5b83\u652f\u6301\u5c07\u6578\u64da\u6301\u4e45\u5316\u5230\u78c1\u789f\uff0c\u78ba\u4fdd\u6578\u64da\u4e0d\u6703\u56e0\u7cfb\u7d71\u5d29\u6f70\u800c\u4e1f\u5931\u3002<\/li>\n<li><strong>\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\uff1a<\/strong>Redis\u652f\u6301\u591a\u7a2e\u6578\u64da\u7d50\u69cb\uff0c\u9019\u4f7f\u5f97\u958b\u767c\u8005\u53ef\u4ee5\u6839\u64da\u5177\u9ad4\u9700\u6c42\u9078\u64c7\u6700\u5408\u9069\u7684\u6578\u64da\u985e\u578b\u3002<\/li>\n<\/ul>\n<h2 id=\"redis%e5%9c%a8%e7%89%a9%e8%81%af%e7%b6%b2%e4%b8%ad%e7%9a%84%e6%87%89%e7%94%a8-ZkpzzPJWgR\">Redis\u5728\u7269\u806f\u7db2\u4e2d\u7684\u61c9\u7528<\/h2>\n<p>\u5728\u7269\u806f\u7db2\u74b0\u5883\u4e2d\uff0c\u8a2d\u5099\u751f\u6210\u7684\u6578\u64da\u91cf\u5de8\u5927\uff0c\u4e14\u6578\u64da\u7684\u751f\u6210\u901f\u5ea6\u6975\u5feb\u3002Redis\u7684\u9ad8\u6027\u80fd\u7279\u6027\u4f7f\u5176\u6210\u70ba\u8655\u7406\u9019\u4e9b\u6578\u64da\u7684\u7406\u60f3\u9078\u64c7\u3002\u4ee5\u4e0b\u662f\u5e7e\u500bRedis\u5728\u7269\u806f\u7db2\u4e2d\u7684\u5177\u9ad4\u61c9\u7528\u6848\u4f8b\uff1a<\/p>\n<h3 id=\"1-%e5%af%a6%e6%99%82%e6%95%b8%e6%93%9a%e8%99%95%e7%90%86-ZkpzzPJWgR\">1. \u5be6\u6642\u6578\u64da\u8655\u7406<\/h3>\n<p>\u7269\u806f\u7db2\u8a2d\u5099\u5982\u667a\u80fd\u5bb6\u5c45\u3001\u5de5\u696d\u50b3\u611f\u5668\u7b49\uff0c\u6703\u4e0d\u65b7\u751f\u6210\u5be6\u6642\u6578\u64da\u3002\u4f7f\u7528Redis\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u5feb\u901f\u5b58\u5132\u548c\u6aa2\u7d22\u9019\u4e9b\u6578\u64da\u3002\u4f8b\u5982\uff0c\u7576\u4e00\u500b\u667a\u80fd\u6eab\u63a7\u5668\u767c\u9001\u6eab\u5ea6\u6578\u64da\u6642\uff0cRedis\u53ef\u4ee5\u7acb\u5373\u5c07\u5176\u5b58\u5132\u4e26\u63d0\u4f9b\u5373\u6642\u67e5\u8a62\u3002<\/p>\n<pre><code>SET temperature:living_room 22.5\nGET temperature:living_room\n<\/code><\/pre>\n<h3 id=\"2-%e6%95%b8%e6%93%9a%e7%b7%a9%e5%ad%98-ZkpzzPJWgR\">2. \u6578\u64da\u7de9\u5b58<\/h3>\n<p>\u5728\u7269\u806f\u7db2\u61c9\u7528\u4e2d\uff0c\u7d93\u5e38\u9700\u8981\u5f9e\u5f8c\u7aef\u670d\u52d9\u5668\u7372\u53d6\u6578\u64da\u3002\u4f7f\u7528Redis\u4f5c\u70ba\u7de9\u5b58\u5c64\uff0c\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u6578\u64da\u8a2a\u554f\u901f\u5ea6\uff0c\u6e1b\u5c11\u5f8c\u7aef\u670d\u52d9\u5668\u7684\u8ca0\u64d4\u3002\u4f8b\u5982\uff0c\u7576\u7528\u6236\u67e5\u8a62\u67d0\u500b\u8a2d\u5099\u7684\u72c0\u614b\u6642\uff0c\u7cfb\u7d71\u53ef\u4ee5\u9996\u5148\u6aa2\u67e5Redis\u7de9\u5b58\uff0c\u5982\u679c\u6578\u64da\u5b58\u5728\uff0c\u5247\u76f4\u63a5\u8fd4\u56de\uff0c\u5426\u5247\u518d\u5f9e\u5f8c\u7aef\u7372\u53d6\u3002<\/p>\n<pre><code>GET device_status:device_id\n<\/code><\/pre>\n<h3 id=\"3-%e6%b6%88%e6%81%af%e9%9a%8a%e5%88%97-ZkpzzPJWgR\">3. \u6d88\u606f\u968a\u5217<\/h3>\n<p>\u7269\u806f\u7db2\u8a2d\u5099\u4e4b\u9593\u7684\u901a\u4fe1\u901a\u5e38\u9700\u8981\u9ad8\u6548\u7684\u6d88\u606f\u50b3\u905e\u6a5f\u5236\u3002Redis\u7684\u767c\u5e03\/\u8a02\u95b1\u529f\u80fd\u53ef\u4ee5\u5be6\u73fe\u8a2d\u5099\u4e4b\u9593\u7684\u5373\u6642\u6d88\u606f\u50b3\u905e\u3002\u4f8b\u5982\uff0c\u7576\u4e00\u500b\u8a2d\u5099\u767c\u9001\u72c0\u614b\u66f4\u65b0\u6642\uff0c\u5176\u4ed6\u8a02\u95b1\u8a72\u6d88\u606f\u7684\u8a2d\u5099\u53ef\u4ee5\u7acb\u5373\u63a5\u6536\u5230\u66f4\u65b0\u4fe1\u606f\u3002<\/p>\n<pre><code>PUBLISH device_updates \"Device 1 is online\"\n<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-ZkpzzPJWgR\">\u7d50\u8ad6<\/h2>\n<p>\u96a8\u8457\u7269\u806f\u7db2\u6280\u8853\u7684\u6301\u7e8c\u767c\u5c55\uff0c\u5c0d\u65bc\u6578\u64da\u5b58\u5132\u548c\u8655\u7406\u7684\u9700\u6c42\u5c07\u8d8a\u4f86\u8d8a\u9ad8\u3002Redis\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\uff0c\u80fd\u5920\u5e6b\u52a9\u4f01\u696d\u5feb\u901f\u61c9\u5c0d\u9019\u4e9b\u6311\u6230\u3002\u7121\u8ad6\u662f\u5728\u5be6\u6642\u6578\u64da\u8655\u7406\u3001\u6578\u64da\u7de9\u5b58\u9084\u662f\u6d88\u606f\u968a\u5217\u65b9\u9762\uff0cRedis\u90fd\u5c55\u73fe\u51fa\u4e86\u5176\u5f37\u5927\u7684\u80fd\u529b\u3002\u5c0d\u65bc\u5e0c\u671b\u5728\u7269\u806f\u7db2\u9818\u57df\u53d6\u5f97\u6210\u529f\u7684\u4f01\u696d\u4f86\u8aaa\uff0c\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab\u6280\u8853\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bc\u5982\u4f55\u5229\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u548c\u5176\u4ed6\u96f2\u670d\u52d9\u4f86\u652f\u6301\u60a8\u7684\u7269\u806f\u7db2\u61c9\u7528\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redis\u6578\u64da\u5eab\u52a9\u529b\u7269\u806f\u7db2\u84ec\u52c3\u767c\u5c55\uff0c\u63d0\u4f9b\u9ad8\u6548\u6578\u64da\u8655\u7406\u8207\u5be6\u6642\u5206\u6790\uff0c\u63d0\u5347\u667a\u80fd\u8a2d\u5099\u7684\u6027\u80fd\u8207\u53cd\u61c9\u901f\u5ea6\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-190720","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190720","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=190720"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190720\/revisions"}],"predecessor-version":[{"id":190721,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190720\/revisions\/190721"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=190720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=190720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=190720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}