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

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

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

        <tfoot id='hwLCp'></tfoot>

        DynamoDB 和 TableNameOverride 带前缀

        时间:2023-06-26

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

            <tbody id='TMLba'></tbody>

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

                <legend id='TMLba'><style id='TMLba'><dir id='TMLba'><q id='TMLba'></q></dir></style></legend>
                • <bdo id='TMLba'></bdo><ul id='TMLba'></ul>
                • 本文介绍了DynamoDB 和 TableNameOverride 带前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在测试 DynamoDB 表,并希望使用前缀dev_"为 prod 和 dev 环境设置不同的表名以进行开发.

                  I am testing DynamoDB tables and want to set up different table names for prod and dev environment using the prefix "dev_" for development.

                  我做了这个测试来打印表名:

                  I made this test to print the table name:

                  import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig.TableNameOverride;  
                  
                  TableNameOverride tbl = new TableNameOverride("test").withTableNamePrefix("dev_");
                  System.out.println("name=" + tbl.getTableName() + "  prefix=" + tbl.getTableNamePrefix());
                  

                  这打印:name=null prefix=dev_
                  这里的名字怎么是空的?

                  This prints: name=null prefix=dev_
                  How come the name here is null ?

                  TableNameOverride tbl = new TableNameOverride("test");//.withTableNamePrefix("dev_");
                  System.out.println("name=" + tbl.getTableName() + "  prefix=" + tbl.getTableNamePrefix());
                  

                  这打印:name=test prefix=null

                  *如何让表名成为dev_test"?*

                  我想稍后使用它为开发模式下的所有表获取dev_"前缀,如下所示:

                  I want to use this later to get a "dev_" prefix for all tables in development mode like this:

                  DynamoDBTable annotation = (DynamoDBTable) myclass.getClass().getAnnotation(DynamoDBTable.class);  
                  TableNameOverride tbl = new TableNameOverride(annotation.tableName()).withTableNamePrefix("dev_");
                  

                  或者是否有另一种解决方案来分隔 dev 表和 prod 表?
                  我首先想到将它们放在不同的区域,但不确定.

                  Or is there another solution to separate between dev and prod tables?
                  I first thought of putting them in separate regions but not sure about this.

                  也可以这样用:

                  mapper.save(ck, new DynamoDBMapperConfig(new TableNameOverride((isDev ? "dev_" : "") + annotation.tableName())));
                  

                  推荐答案

                  withTableNamePrefix 是一个静态方法.因此,这一行使用字符串test"创建 TableNameOverride 的新实例,然后通过调用静态 withTableNamePrefix 方法将该实例丢弃:

                  withTableNamePrefix is a static method. So this line is creating a new instance of TableNameOverride with the String "test", and then throwing that instance away by using it to call the static withTableNamePrefix method:

                  TableNameOverride tbl = new TableNameOverride("test").withTableNamePrefix("dev_");
                  

                  要回答将测试与生产分开的更深层次的问题,我建议完全拥有 2 个单独的 AWS 账户,一个用于开发,一个用于生产.这是您可以做到的唯一方法:

                  To answer the deeper question of separating test from prod, I would recommend having 2 separate AWS Accounts entirely, one for dev and one for prod. This is the only way you can:

                  • 单独查看帐单
                  • 确保您绝不在产品和测试系统之间泄露数据
                  • 在 dev 表上进行高扩展会阻止您将 prod 表扩展得更高
                  • See billing separately
                  • Ensure you never leak data between prod and test systems
                  • Have high scaling on a dev table prevent you from scaling a prod table higher

                  这篇关于DynamoDB 和 TableNameOverride 带前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:作为 Gradle Java 项目的一部分在本地运行 Dynamodb 下一篇:Dynamo DB 中的自动递增计数器

                  相关文章

                  <legend id='Mck6I'><style id='Mck6I'><dir id='Mck6I'><q id='Mck6I'></q></dir></style></legend>
                • <small id='Mck6I'></small><noframes id='Mck6I'>

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