Google 将什么归类为 Google App Engine 中的数据存储区写入操作? [英] What does Google classify as a datastore write operation in Google App Engine?

查看:23
本文介绍了Google 将什么归类为 Google App Engine 中的数据存储区写入操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从 GAE 在上周初进入定价模型以来,我一直在努力解决超出我的 Datastore 读写操作配额的问题.我不确定 Google 是将一位作者的所有更新都计为一次写入,还是将每个列更新都计为一次单独的写入.

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.

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

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);
}
        }

推荐答案

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

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.

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

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.

这篇关于Google 将什么归类为 Google App Engine 中的数据存储区写入操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆