Riak 中的桶是什么?它的用途

What is Bucket in Riak? what its used for

Riak 中的桶是什么?我试图查看文档,但我提到了 buckets 类型,但无法理解 Riak 中 bucket 的概念。

有什么解释吗?它是什么,为什么使用它?

我认为除了“存储桶是一种分配了一些配置的数据分组机制”之外,我认为它没有更多的意义。

引用 official docs(强调我的):

Buckets are used to define a virtual keyspace for storing Riak objects. They enable you to define non-default configurations over that keyspace concerning replication properties and other parameters.

In certain respects, buckets can be compared to tables in relational databases or folders in filesystems, respectively. From the standpoint of performance, buckets with default configurations are essentially “free,” while non-default configurations, defined using bucket types, will be gossiped around [the ring][glossary read rep] using Riak’s cluster metadata subsystem.

来自Bucket Types

Buckets are essentially a flat namespace in Riak. They allow the same key name to exist in multiple buckets and enable you to apply configurations across keys.

Bucket : 在某些方面,bucket 可以与关系数据库中的表或文件系统中的文件夹进行比较

桶类型

  1. Riak 2.0 的新特性
  2. 桶类型允许桶组共享配置细节。这允许 Riak 用户和管理员比基于存储桶属性的旧配置系统更有效地管理存储桶属性

让我们再深入一点:

使用桶类型文档非常详细地介绍了桶类型的实现、使用和配置。在整个文档中,有代码示例(例如使用数据类型),包括用于创建与每个单独的 Riak 数据类型关联的存储桶类型的代码。

桶类型是对旧桶配置系统的重大改进。定义桶配置,然后在必要时为整组桶更改配置的能力,是考虑数据建模的一种强大的新方法。此外,桶类型更可靠,因为具有给定类型(或配置)的桶仅在类型更改时更改其属性。以前,只能通过客户端请求更改存储桶的属性。

在之前的 Riak 版本中,bucket 属性会被与 Riak 交互的客户端改变……相比之下,bucket 类型是一个操作概念。 riak-admin bucket-type 接口使 Riak 用户能够在操作级别管理 bucket 配置,而无需求助于 Riak 客户端。

在 2.0 之前的 Riak 版本中,所有查询都是针对 bucket/key 对进行的,如下例所示:

curl http://localhost:8098/buckets/my_bucket/keys/my_key

现在在 Riak 2.0 中添加了桶类型,在桶和键之上有一个额外的命名空间。如果按照不同的bucket类型使用,同一个bucket名称可以关联完全不同的数据。

curl http://localhost:8098/types/type1/buckets/my_bucket/keys/my_key
curl http://localhost:8098/types/type2/buckets/my_bucket/keys/my_key

如果向 bucket/key 对发出请求而没有指定存储桶类型,将使用 default 代替存储桶类型。以下请求相同。

curl http://localhost:8098/buckets/my_bucket/keys/my_key
curl http://localhost:8098/types/default/my_bucket/keys/my_key