在 Riak 中如何组织存储桶?

发布于 2024-11-09 20:54:13 字数 202 浏览 4 评论 0原文

由于 Riak 使用桶作为分隔键的方式,那么桶内是否有可能存在桶呢?如果不是,如何为多个应用程序组织一个包含多个存储桶的 Riak 设置。

基本问题是如何在 Riak 中表示“数据库”和“表”。既然存储桶可以转换为表,那么什么可以转换为数据库呢?

编程语言中的命名空间通常具有层次结构。 Riak 存储桶也允许层次结构是有意义的,因为存储桶本质上是命名空间。

Since Riak uses buckets as a way of separating keys, is it possible to have buckets within buckets? If not how would one go about organizing a Riak setup with many buckets for several apps.

The basic problem is how one would go about representing "databases" and "tables" within Riak. Since a bucket translates to a table, what translates to a database?

Namespaces in programming languages usually have hierarchies. It makes sense for Riak buckets to also allow hierarchies, since buckets are essentially namespaces.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

演多会厌 2024-11-16 20:54:13

您需要将 Riak 视为非常大的密钥 -> value “table”,其中 存储桶只是键的前缀。现在,您知道只要存储桶仍然是二进制对象,您就可以对它们执行任何操作。

您可以创建线性“表”:

<<"table1">>
<<"table2">>

或者您可以创建层次结构:

<<"db1.table1">>
<<"db1.table2">>
<<"db2.table1">>
<<"db2.table2">>

或者您甚至可以使用元组作为存储桶:

1> term_to_binary({"db1", "table1"}).
<<131,104,2,107,0,3,100,98,49,107,0,6,116,97,98,108,101,49>>
2> term_to_binary({"db1", "table2"}).
<<131,104,2,107,0,3,100,98,49,107,0,6,116,97,98,108,101,50>>
3> term_to_binary({"db2", "table1"}).
<<131,104,2,107,0,3,100,98,50,107,0,6,116,97,98,108,101,49>>
4> term_to_binary({"db2", "table2"}).
<<131,104,2,107,0,3,100,98,50,107,0,6,116,97,98,108,101,50>>

You need to think about Riak as about very big key -> value "table" where buckets are only prefixes for keys. Now when you know that you can do anything with buckets as long as they are still binary objects.

You can create linear "tables":

<<"table1">>
<<"table2">>

Or you can create hierarchies:

<<"db1.table1">>
<<"db1.table2">>
<<"db2.table1">>
<<"db2.table2">>

Or you even can use tuples as buckets:

1> term_to_binary({"db1", "table1"}).
<<131,104,2,107,0,3,100,98,49,107,0,6,116,97,98,108,101,49>>
2> term_to_binary({"db1", "table2"}).
<<131,104,2,107,0,3,100,98,49,107,0,6,116,97,98,108,101,50>>
3> term_to_binary({"db2", "table1"}).
<<131,104,2,107,0,3,100,98,50,107,0,6,116,97,98,108,101,49>>
4> term_to_binary({"db2", "table2"}).
<<131,104,2,107,0,3,100,98,50,107,0,6,116,97,98,108,101,50>>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文