{"id":194477,"date":"2024-11-13T06:59:18","date_gmt":"2024-11-12T22:59:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/194477\/"},"modified":"2024-11-13T06:59:19","modified_gmt":"2024-11-12T22:59:19","slug":"%e6%93%81%e6%8a%b1%e6%96%b0%e6%99%82%e4%bb%a3%e6%9b%bf%e4%bb%a3redis%e7%9a%84nosql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%94%a2%e5%93%81%ef%bc%88redis%e7%9a%84%e4%bb%a3%e6%9b%bf%e7%94%a2%e5%93%81%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/194477\/","title":{"rendered":"\u64c1\u62b1\u65b0\u6642\u4ee3\u66ff\u4ee3Redis\u7684NoSQL\u6578\u64da\u5eab\u7522\u54c1\uff08redis\u7684\u4ee3\u66ff\u7522\u54c1\uff09"},"content":{"rendered":"<h1 id=\"%e6%93%81%e6%8a%b1%e6%96%b0%e6%99%82%e4%bb%a3%e6%9b%bf%e4%bb%a3redis%e7%9a%84nosql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%94%a2%e5%93%81-qLQUAzFPni\">\u64c1\u62b1\u65b0\u6642\u4ee3\u66ff\u4ee3Redis\u7684NoSQL\u6578\u64da\u5eab\u7522\u54c1<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0cNoSQL\u6578\u64da\u5eab\u56e0\u5176\u9748\u6d3b\u6027\u548c\u53ef\u64f4\u5c55\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u95dc\u6ce8\u3002Redis\u4f5c\u70ba\u4e00\u7a2e\u6d41\u884c\u7684\u5167\u5b58\u6578\u64da\u7d50\u69cb\u5b58\u5132\uff0c\u96d6\u7136\u5728\u6027\u80fd\u4e0a\u8868\u73fe\u512a\u7570\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u5c0b\u6c42\u5176\u4ed6\u66ff\u4ee3\u65b9\u6848\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5e7e\u7a2e\u53ef\u4ee5\u66ff\u4ee3Redis\u7684NoSQL\u6578\u64da\u5eab\u7522\u54c1\uff0c\u4e26\u5206\u6790\u5b83\u5011\u7684\u7279\u9ede\u548c\u9069\u7528\u5834\u666f\u3002<\/p>\n<h2 id=\"1-mongodb-qLQUAzFPni\">1. MongoDB<\/h2>\n<p>MongoDB\u662f\u4e00\u7a2e\u6587\u6a94\u5c0e\u5411\u7684NoSQL\u6578\u64da\u5eab\uff0c\u4f7f\u7528JSON\u985e\u4f3c\u7684BSON\u683c\u5f0f\u4f86\u5b58\u5132\u6578\u64da\u3002\u5b83\u7684\u4e3b\u8981\u512a\u52e2\u5728\u65bc\u9748\u6d3b\u7684\u6578\u64da\u6a21\u578b\u548c\u5f37\u5927\u7684\u67e5\u8a62\u529f\u80fd\u3002MongoDB\u652f\u6301\u8907\u96dc\u7684\u67e5\u8a62\u548c\u7d22\u5f15\uff0c\u9069\u5408\u9700\u8981\u9ad8\u53ef\u7528\u6027\u548c\u53ef\u64f4\u5c55\u6027\u7684\u61c9\u7528\u3002<\/p>\n<ul>\n<li><strong>\u512a\u52e2\uff1a<\/strong>\u9748\u6d3b\u7684\u6578\u64da\u7d50\u69cb\uff0c\u652f\u6301\u8907\u96dc\u67e5\u8a62\u3002<\/li>\n<li><strong>\u9069\u7528\u5834\u666f\uff1a<\/strong>\u5167\u5bb9\u7ba1\u7406\u7cfb\u7d71\u3001\u793e\u4ea4\u5a92\u9ad4\u61c9\u7528\u3001\u5be6\u6642\u5206\u6790\u3002<\/li>\n<\/ul>\n<h3 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a2%bc-qLQUAzFPni\">\u793a\u4f8b\u4ee3\u78bc<\/h3>\n<pre><code>\ndb.collection.insertOne({\n    name: \"John Doe\",\n    age: 30,\n    hobbies: [\"reading\", \"gaming\"]\n});\n<\/code><\/pre>\n<h2 id=\"2-cassandra-qLQUAzFPni\">2. Cassandra<\/h2>\n<p>Cassandra\u662f\u4e00\u7a2e\u5206\u4f48\u5f0fNoSQL\u6578\u64da\u5eab\uff0c\u5c08\u70ba\u8655\u7406\u5927\u91cf\u6578\u64da\u800c\u8a2d\u8a08\u3002\u5b83\u7684\u9ad8\u53ef\u7528\u6027\u548c\u7121\u55ae\u9ede\u6545\u969c\u7684\u7279\u6027\u4f7f\u5176\u6210\u70ba\u5927\u898f\u6a21\u61c9\u7528\u7684\u7406\u60f3\u9078\u64c7\u3002Cassandra\u4f7f\u7528\u5217\u65cf\u5b58\u5132\u6578\u64da\uff0c\u4e26\u652f\u6301\u6c34\u5e73\u64f4\u5c55\u3002<\/p>\n<ul>\n<li><strong>\u512a\u52e2\uff1a<\/strong>\u9ad8\u53ef\u7528\u6027\u3001\u53ef\u64f4\u5c55\u6027\u5f37\u3002<\/li>\n<li><strong>\u9069\u7528\u5834\u666f\uff1a<\/strong>\u7269\u806f\u7db2\u3001\u5927\u6578\u64da\u5206\u6790\u3001\u5be6\u6642\u6578\u64da\u8655\u7406\u3002<\/li>\n<\/ul>\n<h3 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a2%bc-qLQUAzFPni\">\u793a\u4f8b\u4ee3\u78bc<\/h3>\n<pre><code>\nCREATE TABLE users (\n    user_id UUID PRIMARY KEY,\n    name TEXT,\n    age INT\n);\n<\/code><\/pre>\n<h2 id=\"3-couchbase-qLQUAzFPni\">3. Couchbase<\/h2>\n<p>Couchbase\u7d50\u5408\u4e86\u6587\u6a94\u5b58\u5132\u548c\u9375\u503c\u5b58\u5132\u7684\u7279\u6027\uff0c\u63d0\u4f9b\u4e86\u9ad8\u6027\u80fd\u7684\u6578\u64da\u5b58\u53d6\u3002\u5b83\u7684\u5167\u5b58\u512a\u5148\u67b6\u69cb\u4f7f\u5f97\u8b80\u53d6\u548c\u5beb\u5165\u64cd\u4f5c\u90fd\u975e\u5e38\u8fc5\u901f\uff0c\u9069\u5408\u9700\u8981\u5feb\u901f\u97ff\u61c9\u7684\u61c9\u7528\u3002<\/p>\n<ul>\n<li><strong>\u512a\u52e2\uff1a<\/strong>\u9ad8\u6027\u80fd\u3001\u652f\u6301\u591a\u7a2e\u6578\u64da\u6a21\u578b\u3002<\/li>\n<li><strong>\u9069\u7528\u5834\u666f\uff1a<\/strong>\u79fb\u52d5\u61c9\u7528\u3001\u904a\u6232\u5f8c\u7aef\u3001\u5373\u6642\u5206\u6790\u3002<\/li>\n<\/ul>\n<h3 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a2%bc-qLQUAzFPni\">\u793a\u4f8b\u4ee3\u78bc<\/h3>\n<pre><code>\nINSERT INTO `users` (KEY, VALUE) VALUES\n(\"user::1\", {\"name\": \"Alice\", \"age\": 25});\n<\/code><\/pre>\n<h2 id=\"4-amazon-dynamodb-qLQUAzFPni\">4. Amazon DynamoDB<\/h2>\n<p>DynamoDB\u662f\u4e9e\u99ac\u905c\u63d0\u4f9b\u7684\u5b8c\u5168\u8a17\u7ba1\u7684NoSQL\u6578\u64da\u5eab\u670d\u52d9\uff0c\u5177\u6709\u81ea\u52d5\u64f4\u5c55\u548c\u9ad8\u53ef\u7528\u6027\u3002\u5b83\u652f\u6301\u9375\u503c\u548c\u6587\u6a94\u6578\u64da\u6a21\u578b\uff0c\u4e26\u4e14\u80fd\u5920\u8655\u7406\u5927\u898f\u6a21\u7684\u8acb\u6c42\u3002<\/p>\n<ul>\n<li><strong>\u512a\u52e2\uff1a<\/strong>\u5b8c\u5168\u8a17\u7ba1\u3001\u7121\u9700\u7dad\u8b77\u3002<\/li>\n<li><strong>\u9069\u7528\u5834\u666f\uff1a<\/strong>\u96fb\u5b50\u5546\u52d9\u3001\u904a\u6232\u3001\u79fb\u52d5\u61c9\u7528\u3002<\/li>\n<\/ul>\n<h3 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a2%bc-qLQUAzFPni\">\u793a\u4f8b\u4ee3\u78bc<\/h3>\n<pre><code>\nconst AWS = require('aws-sdk');\nconst dynamoDB = new AWS.DynamoDB.DocumentClient();\n\nconst params = {\n    TableName: 'Users',\n    Item: {\n        userId: '1',\n        name: 'Bob',\n        age: 28\n    }\n};\n\ndynamoDB.put(params, (err, data) =&gt; {\n    if (err) console.log(err);\n    else console.log(\"Data inserted successfully\");\n});\n<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-qLQUAzFPni\">\u7d50\u8ad6<\/h2>\n<p>\u5728\u9078\u64c7NoSQL\u6578\u64da\u5eab\u6642\uff0c\u958b\u767c\u8005\u61c9\u6839\u64da\u5177\u9ad4\u9700\u6c42\u8003\u616e\u4e0d\u540c\u7522\u54c1\u7684\u7279\u6027\u3002MongoDB\u3001Cassandra\u3001Couchbase\u548cDynamoDB\u7b49\u90fd\u662fRedis\u7684\u512a\u79c0\u66ff\u4ee3\u54c1\uff0c\u5404\u81ea\u64c1\u6709\u7368\u7279\u7684\u512a\u52e2\u548c\u9069\u7528\u5834\u666f\u3002\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0c\u9019\u4e9b\u6578\u64da\u5eab\u7522\u54c1\u5c07\u5728\u672a\u4f86\u7684\u61c9\u7528\u4e2d\u767c\u63ee\u8d8a\u4f86\u8d8a\u91cd\u8981\u7684\u4f5c\u7528\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u4f86\u90e8\u7f72\u60a8\u7684NoSQL\u6578\u64da\u5eab\uff0c\u7121\u8ad6\u662fRedis\u9084\u662f\u5176\u4ed6\u66ff\u4ee3\u7522\u54c1\uff0cServer.HK\u90fd\u80fd\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u548c\u670d\u52d9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u64c1\u62b1\u65b0\u6642\u4ee3\u7684NoSQL\u6578\u64da\u5eab\u7522\u54c1\uff0c\u4e86\u89e3Redis\u7684\u66ff\u4ee3\u65b9\u6848\uff0c\u63d0\u5347\u6578\u64da\u8655\u7406\u6548\u7387\u8207\u9748\u6d3b\u6027\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-194477","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/194477","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=194477"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/194477\/revisions"}],"predecessor-version":[{"id":194478,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/194477\/revisions\/194478"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=194477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=194477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=194477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}