Google 将什么分类为 Google App Engine 中的数据存储写入操作?

发布于 2024-12-15 00:10:45 字数 1242 浏览 2 评论 0原文

自从 GAE 在上周初采用定价模型以来,我一直在努力解决超出数据存储读写操作配额的问题。我不确定 Google 是否将一位写入者的所有更新计为一次写入,或者是否将每个列更新计为一次单独的写入。

如果后者是真的,我可以通过使用一个更新函数来更新参数中的 6 列来解决这个问题,还是我还会为 6 次更新付费?

这是我现有的代码,用于同时更新玩家的分数(评级)和其他详细信息。目前,我总是用客户的值来填充姓名、电子邮件、评级、获胜、玩过的游戏和成就。一种解决方案可能是仅在值发生更改时从客户端发送这些值。

Long key = Long.valueOf(updateIdStr);
System.out.println("Key to update: " + key);
PlayerPersistentData ppd =null;
try {
    ppd = pm.getObjectById(
    PlayerPersistentData.class, key);
// for all of these, make sure we actually got a value via
// the query variables
    if (name != null && name.length() > 0) {
        ppd.setName(name);
}

if (ratingStr != null && ratingStr.length() > 0) {
    ppd.setRating(rating);
}

if (playedStr != null && playedStr.length() > 0) {
     ppd.setPlayed(played);
}

if (wonStr != null && wonStr.length() > 0) {
     ppd.setWon(won);
}

if (encryptedAchievements != null
    && encryptedAchievements.length() > 0) {
    ppd.setAchievements(achievements);
}

if (email != null & email.length() > 0) {
    ppd.setEmail(email);
}

resp.getWriter().print(key);
} catch (JDOObjectNotFoundException e) {
    resp.getWriter().print(-1);
}
        }

Since GAE went to the pricing model at the start of last week I have been wrestling with exceeding my quota of Datastore read and write operations. I'm not sure whether Google counts all updates for one writer as one write or whether every column update is counted as a separate write.

If the latter is true could I get around this by having one update function to update the 6 columns in the parameters or do will I also get charged for 6 updates?

Here is my existing code, used to update a player's score (rating) and the other details at the same time. At the moment I always populate name, email, rating, won, played and achievements with values from the client. One solution may be to only send these from the client side when they have changed value.

Long key = Long.valueOf(updateIdStr);
System.out.println("Key to update: " + key);
PlayerPersistentData ppd =null;
try {
    ppd = pm.getObjectById(
    PlayerPersistentData.class, key);
// for all of these, make sure we actually got a value via
// the query variables
    if (name != null && name.length() > 0) {
        ppd.setName(name);
}

if (ratingStr != null && ratingStr.length() > 0) {
    ppd.setRating(rating);
}

if (playedStr != null && playedStr.length() > 0) {
     ppd.setPlayed(played);
}

if (wonStr != null && wonStr.length() > 0) {
     ppd.setWon(won);
}

if (encryptedAchievements != null
    && encryptedAchievements.length() > 0) {
    ppd.setAchievements(achievements);
}

if (email != null & email.length() > 0) {
    ppd.setEmail(email);
}

resp.getWriter().print(key);
} catch (JDOObjectNotFoundException e) {
    resp.getWriter().print(-1);
}
        }

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

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

发布评论

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

评论(2

ぺ禁宫浮华殁 2024-12-22 00:10:45

您需要支付的写入次数取决于您的实体。一般来说,您需要为实体的 1 次写入付费,为每个索引更新 1 次写入付费。每个索引属性都包含在升序和降序单属性索引中,因此每个索引实体至少有 2 次写入,加上复合(用户定义)索引的任何写入。

更新现有实体时,您需要为旧索引和新索引的差异付费。因此,如果您修改一个属性,您将需要支付实体写入费用,再加上内置索引的每个属性 4 次写入(删除旧值并插入新值),对于任何复合索引也是如此。

The number of writes you are charged for depends on your entity. In general, you are charged for 1 write for the entity, and 1 write for each index update. Each indexed property is included in the ascending and descending single-property indexes, so there's a minimum of 2 writes per indexed entity, plus any writes for composite (user-defined) indexes.

When updating an existing entity, you're charged for the diff of the old indexes and the new ones. So if you modify one property, you'll be charged for the entity write, plus 4 writes per property (deleting the old value and inserting the new one) for the built-in indexes, and likewise for any composite indexes.

财迷小姐 2024-12-22 00:10:45

请注意,定价结构的变化将于2016 年 7 月 1 日生效,从按操作更改为按实体。这改变了您对高效(从成本角度)写入数据存储的看法。

新的云数据存储区定价将于 2016 年 7 月 1 日开始

2016 年 7 月 1 日,Google Cloud Datastore 定价将从
按操作收费改为按实体收费。这个就简单多了
定价意味着使用全部功能的成本将大大降低
Google 云数据存储区。

例如,在当前定价下,编写一个新实体,其值为 1
索引属性将花费 4 次写入操作。在新的定价中,
只需要 1 个实体写入。同样,删除该实体
当前定价将花费 4 次写入操作,但在新定价中
只需删除 1 个实体即可。

Note the changes in pricing structure going into effect July 1st, 2016 going from per operation to per entity. This changes how you think about writing efficiently (cost-wise) to Datastore.

New Cloud Datastore Pricing Starting July 1st, 2016

On July 1, 2016, Google Cloud Datastore pricing will change from
charging per operation to charging per entity. This much simpler
pricing means it will cost significantly less to use the full power of
Google Cloud Datastore.

For example, in the current pricing, writing a new entity with 1
indexed property would cost 4 write operations. In the new pricing, it
would cost only 1 entity write. Similarly, deleting this entity in the
current pricing would cost 4 write operations, but in the new pricing
it would cost only 1 entity delete.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文