<small id='z9Qvh'></small><noframes id='z9Qvh'>

    <bdo id='z9Qvh'></bdo><ul id='z9Qvh'></ul>

      <i id='z9Qvh'><tr id='z9Qvh'><dt id='z9Qvh'><q id='z9Qvh'><span id='z9Qvh'><b id='z9Qvh'><form id='z9Qvh'><ins id='z9Qvh'></ins><ul id='z9Qvh'></ul><sub id='z9Qvh'></sub></form><legend id='z9Qvh'></legend><bdo id='z9Qvh'><pre id='z9Qvh'><center id='z9Qvh'></center></pre></bdo></b><th id='z9Qvh'></th></span></q></dt></tr></i><div id='z9Qvh'><tfoot id='z9Qvh'></tfoot><dl id='z9Qvh'><fieldset id='z9Qvh'></fieldset></dl></div>

      <legend id='z9Qvh'><style id='z9Qvh'><dir id='z9Qvh'><q id='z9Qvh'></q></dir></style></legend>

      1. <tfoot id='z9Qvh'></tfoot>

        全球二级索引的 DynamoDB 一致性读取

        时间:2023-09-14
          <bdo id='JaSh1'></bdo><ul id='JaSh1'></ul>

        • <small id='JaSh1'></small><noframes id='JaSh1'>

          <i id='JaSh1'><tr id='JaSh1'><dt id='JaSh1'><q id='JaSh1'><span id='JaSh1'><b id='JaSh1'><form id='JaSh1'><ins id='JaSh1'></ins><ul id='JaSh1'></ul><sub id='JaSh1'></sub></form><legend id='JaSh1'></legend><bdo id='JaSh1'><pre id='JaSh1'><center id='JaSh1'></center></pre></bdo></b><th id='JaSh1'></th></span></q></dt></tr></i><div id='JaSh1'><tfoot id='JaSh1'></tfoot><dl id='JaSh1'><fieldset id='JaSh1'></fieldset></dl></div>

                <tbody id='JaSh1'></tbody>
              <legend id='JaSh1'><style id='JaSh1'><dir id='JaSh1'><q id='JaSh1'></q></dir></style></legend>
                • <tfoot id='JaSh1'></tfoot>

                  本文介绍了全球二级索引的 DynamoDB 一致性读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  为什么我无法获得全局二级索引的一致读取?

                  Why cant I get consistent reads for global-secondary-indexes?

                  我有以下设置:

                  表格:tblUsers(id 为哈希)

                  The table: tblUsers (id as hash)

                  全局二级索引:tblUsersEmailIndex(电子邮件作为哈希,id 作为属性)

                  Global Secondary Index: tblUsersEmailIndex (email as hash, id as attribute)

                  全局二级索引:tblUsersUsernameIndex(用户名作为hash,id作为属性)

                  Global Secondary Index: tblUsersUsernameIndex (username as hash, id as attribute)

                  我查询索引以检查给定的电子邮件或用户名是否存在,因此我不会创建重复的用户.

                  I query the indexes to check if a given email or username is present, so I dont create a duplicate user.

                  现在,问题是我无法对索引的查询进行一致的读取.但为什么不呢?这是我真正需要最新数据的少数场合之一.

                  Now, the problem is I cant do consistent reads for queries on the indexes. But why not? This is one of the few occasions I actually need up-to-date data.

                  根据 AWS 文档:

                  对全局二级索引的查询仅支持最终一致性.

                  Queries on global secondary indexes support eventual consistency only.

                  在正常情况下,对表数据的更改会在几分之一秒内传播到全局二级索引.但是,在一些不太可能发生的故障情况下,可能会出现更长的传播延迟.因此,您的应用程序需要预测和处理对全局二级索引的查询返回的结果不是最新的情况.

                  Changes to the table data are propagated to the global secondary indexes within a fraction of a second, under normal conditions. However, in some unlikely failure scenarios, longer propagation delays might occur. Because of this, your applications need to anticipate and handle situations where a query on a global secondary index returns results that are not up-to-date.

                  但是我该如何处理这种情况呢?如何确保给定的电子邮件或用户名不存在于数据库中?

                  But how do i handle this situation? How can I make sure that a given email or username is not already present in the db?

                  推荐答案

                  你可能已经经历过这个:http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html

                  You probably already went through this: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html

                  简短的回答是,你不能用全局二级索引做你想做的事情(即它总是最终的一致性).

                  The short answer is that you cannot do what you want to do with Global Secondary Indexes (ie it's always eventual consistency).

                  这里的解决方案是有一个单独的表,其中包含您感兴趣的属性作为键,并在那里进行一致的读取.您需要确保在插入新实体时进行更新,并且您还必须担心插入成功但不在主表中的边缘情况(即您需要确保它们同步)

                  A solution here would be to have a separate table w/ the attribute you're interested in as a key and do consistent reads there. You would need to ensure you are updating that whenever you are inserting new entities, and you would also have to worry about the edge case in which inserts there succeed, but not in the main table (ie you need to ensure they are in sync)

                  另一种解决方案是扫描整个表,但如果表很大,这可能会过大.

                  Another solution would be to scan the whole table, but that would probably be overkill if the table is large.

                  您为什么关心有人使用同一电子邮件创建 2 个帐户?您可以只使用用户名作为主哈希键,而不是强制电子邮件唯一性.

                  Why do you care if somebody creates 2 accounts with the same email? You could just use the username as the primary hash key and just not enforce the email uniqueness.

                  这篇关于全球二级索引的 DynamoDB 一致性读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Net Core 2.0 AmazonServiceException:找不到凭证 下一篇:使用 .NET SDK 在 DynamoDB 中持久化动态对象

                  相关文章

                      <bdo id='YkfDu'></bdo><ul id='YkfDu'></ul>

                  1. <legend id='YkfDu'><style id='YkfDu'><dir id='YkfDu'><q id='YkfDu'></q></dir></style></legend>

                  2. <tfoot id='YkfDu'></tfoot>

                    <small id='YkfDu'></small><noframes id='YkfDu'>

                    <i id='YkfDu'><tr id='YkfDu'><dt id='YkfDu'><q id='YkfDu'><span id='YkfDu'><b id='YkfDu'><form id='YkfDu'><ins id='YkfDu'></ins><ul id='YkfDu'></ul><sub id='YkfDu'></sub></form><legend id='YkfDu'></legend><bdo id='YkfDu'><pre id='YkfDu'><center id='YkfDu'></center></pre></bdo></b><th id='YkfDu'></th></span></q></dt></tr></i><div id='YkfDu'><tfoot id='YkfDu'></tfoot><dl id='YkfDu'><fieldset id='YkfDu'></fieldset></dl></div>