{"id":125013,"date":"2024-10-25T19:04:18","date_gmt":"2024-10-25T11:04:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/125013\/"},"modified":"2024-10-25T19:04:19","modified_gmt":"2024-10-25T11:04:19","slug":"redis-%e7%b0%a1%e6%98%93%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97%e8%ae%93%e4%bd%a0%e5%bf%ab%e9%80%9f%e4%b8%8a%e6%89%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/125013\/","title":{"rendered":"Redis \u7c21\u6613\u4f7f\u7528\u6307\u5357\u8b93\u4f60\u5feb\u901f\u4e0a\u624b"},"content":{"rendered":"<h1 id=\"redis-%e7%b0%a1%e6%98%93%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97%e8%ae%93%e4%bd%a0%e5%bf%ab%e9%80%9f%e4%b8%8a%e6%89%8b-ARScQTsYzn\">Redis \u7c21\u6613\u4f7f\u7528\u6307\u5357\u8b93\u4f60\u5feb\u901f\u4e0a\u624b<\/h1>\n<p>Redis \u662f\u4e00\u500b\u958b\u6e90\u7684\u9ad8\u6027\u80fd\u9375\u503c\u6578\u64da\u5eab\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u7de9\u5b58\u3001\u6d88\u606f\u968a\u5217\u548c\u6578\u64da\u5b58\u5132\u7b49\u5834\u666f\u3002\u7531\u65bc\u5176\u9ad8\u6548\u7684\u6027\u80fd\u548c\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\uff0cRedis \u6210\u70ba\u4e86\u8a31\u591a\u958b\u767c\u8005\u7684\u9996\u9078\u3002\u672c\u6587\u5c07\u4ecb\u7d39 Redis \u7684\u57fa\u672c\u6982\u5ff5\u3001\u5b89\u88dd\u6b65\u9a5f\u4ee5\u53ca\u5e38\u7528\u547d\u4ee4\uff0c\u5e6b\u52a9\u4f60\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-redis%ef%bc%9f-ARScQTsYzn\">\u4ec0\u9ebc\u662f Redis\uff1f<\/h2>\n<p>Redis\uff08REmote DIctionary Server\uff09\u662f\u4e00\u500b\u57fa\u65bc\u5167\u5b58\u7684\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\u5b83\u7684\u4e3b\u8981\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u9ad8\u6027\u80fd\uff1a<\/strong>Redis \u53ef\u4ee5\u6bcf\u79d2\u8655\u7406\u6578\u5341\u842c\u6b21\u7684\u8b80\u5beb\u64cd\u4f5c\u3002<\/li>\n<li><strong>\u6301\u4e45\u5316\uff1a<\/strong>\u652f\u6301\u5c07\u6578\u64da\u6301\u4e45\u5316\u5230\u78c1\u789f\uff0c\u907f\u514d\u6578\u64da\u4e1f\u5931\u3002<\/li>\n<li><strong>\u652f\u6301\u591a\u7a2e\u6578\u64da\u7d50\u69cb\uff1a<\/strong>\u9664\u4e86\u57fa\u672c\u7684\u9375\u503c\u5c0d\uff0c\u9084\u652f\u6301\u8907\u96dc\u7684\u6578\u64da\u7d50\u69cb\u3002<\/li>\n<li><strong>\u5206\u4f48\u5f0f\uff1a<\/strong>\u652f\u6301\u4e3b\u5f9e\u8907\u88fd\u548c\u5206\u7247\uff0c\u65b9\u4fbf\u64f4\u5c55\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d-redis-ARScQTsYzn\">\u5b89\u88dd Redis<\/h2>\n<p>\u5728\u958b\u59cb\u4f7f\u7528 Redis \u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88dd\u5b83\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd Redis \u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"%e5%9c%a8-linux-%e4%b8%8a%e5%ae%89%e8%a3%9d-redis-ARScQTsYzn\">\u5728 Linux \u4e0a\u5b89\u88dd Redis<\/h3>\n<pre><code>sudo apt update\nsudo apt install redis-server\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 Redis \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start redis\n<\/code><\/pre>\n<p>\u8981\u6aa2\u67e5 Redis \u662f\u5426\u6b63\u5e38\u904b\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre><code>redis-cli ping\n<\/code><\/pre>\n<p>\u5982\u679c\u8fd4\u56de <code>PONG<\/code>\uff0c\u5247\u8868\u793a Redis \u6b63\u5728\u904b\u884c\u3002<\/p>\n<h3 id=\"%e5%9c%a8-windows-%e4%b8%8a%e5%ae%89%e8%a3%9d-redis-ARScQTsYzn\">\u5728 Windows \u4e0a\u5b89\u88dd Redis<\/h3>\n<p>\u5728 Windows \u4e0a\u5b89\u88dd Redis \u53ef\u4ee5\u4f7f\u7528 Windows Subsystem for Linux (WSL) \u6216\u8005\u76f4\u63a5\u4e0b\u8f09 Windows \u7248\u672c\u7684 Redis\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 WSL \u7684\u6b65\u9a5f\uff1a<\/p>\n<pre><code>curl -fsSL https:\/\/packages.redis.io\/gpg | sudo apt-key add -\nsudo add-apt-repository \"deb http:\/\/packages.redis.io\/deb $(lsb_release -cs) main\"\nsudo apt update\nsudo apt install redis\n<\/code><\/pre>\n<h2 id=\"redis-%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4-ARScQTsYzn\">Redis \u5e38\u7528\u547d\u4ee4<\/h2>\n<p>\u4e86\u89e3\u4e86\u5b89\u88dd\u6b65\u9a5f\u5f8c\uff0c\u63a5\u4e0b\u4f86\u6211\u5011\u4f86\u770b\u770b\u4e00\u4e9b\u5e38\u7528\u7684 Redis \u547d\u4ee4\uff1a<\/p>\n<h3 id=\"%e5%9f%ba%e6%9c%ac%e6%93%8d%e4%bd%9c-ARScQTsYzn\">\u57fa\u672c\u64cd\u4f5c<\/h3>\n<ul>\n<li><code>SET key value<\/code>\uff1a\u8a2d\u7f6e\u9375\u7684\u503c\u3002<\/li>\n<li><code>GET key<\/code>\uff1a\u7372\u53d6\u9375\u7684\u503c\u3002<\/li>\n<li><code>DEL key<\/code>\uff1a\u522a\u9664\u9375\u3002<\/li>\n<\/ul>\n<h3 id=\"%e6%95%b8%e6%93%9a%e7%b5%90%e6%a7%8b%e6%93%8d%e4%bd%9c-ARScQTsYzn\">\u6578\u64da\u7d50\u69cb\u64cd\u4f5c<\/h3>\n<ul>\n<li><code>LPUSH list value<\/code>\uff1a\u5c07\u503c\u63a8\u5165\u5217\u8868\u7684\u5de6\u5074\u3002<\/li>\n<li><code>LRANGE list start stop<\/code>\uff1a\u7372\u53d6\u5217\u8868\u4e2d\u6307\u5b9a\u7bc4\u570d\u7684\u5143\u7d20\u3002<\/li>\n<li><code>SADD set value<\/code>\uff1a\u5c07\u503c\u6dfb\u52a0\u5230\u96c6\u5408\u4e2d\u3002<\/li>\n<li><code>SMEMBERS set<\/code>\uff1a\u7372\u53d6\u96c6\u5408\u4e2d\u7684\u6240\u6709\u6210\u54e1\u3002<\/li>\n<\/ul>\n<h3 id=\"%e6%8c%81%e4%b9%85%e5%8c%96%e6%93%8d%e4%bd%9c-ARScQTsYzn\">\u6301\u4e45\u5316\u64cd\u4f5c<\/h3>\n<ul>\n<li><code>SAVE<\/code>\uff1a\u624b\u52d5\u89f8\u767c\u6301\u4e45\u5316\u3002<\/li>\n<li><code>BGSAVE<\/code>\uff1a\u5728\u80cc\u666f\u4e2d\u89f8\u767c\u6301\u4e45\u5316\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-ARScQTsYzn\">\u7d50\u8ad6<\/h2>\n<p>Redis \u662f\u4e00\u500b\u529f\u80fd\u5f37\u5927\u4e14\u9748\u6d3b\u7684\u6578\u64da\u5eab\uff0c\u9069\u5408\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u5834\u666f\u3002\u901a\u904e\u672c\u6587\u7684\u4ecb\u7d39\uff0c\u4f60\u61c9\u8a72\u80fd\u5920\u5feb\u901f\u4e0a\u624b Redis\uff0c\u4e26\u958b\u59cb\u4f7f\u7528\u5b83\u4f86\u63d0\u5347\u4f60\u7684\u61c9\u7528\u6027\u80fd\u3002\u5982\u679c\u4f60\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u4f86\u904b\u884c Redis\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u9084\u662f\u5176\u4ed6\u5730\u5340\u7684\u670d\u52d9\uff0c\u5747\u53ef\u70ba\u4f60\u7684\u9805\u76ee\u63d0\u4f9b\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redis \u7c21\u6613\u4f7f\u7528\u6307\u5357\uff0c\u5e6b\u52a9\u4f60\u5feb\u901f\u4e0a\u624b\uff0c\u638c\u63e1\u57fa\u672c\u64cd\u4f5c\u8207\u6700\u4f73\u5be6\u8e10\uff0c\u63d0\u5347\u6578\u64da\u8655\u7406\u6548\u7387\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-125013","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/125013","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=125013"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/125013\/revisions"}],"predecessor-version":[{"id":125014,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/125013\/revisions\/125014"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=125013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=125013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=125013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}