Google将哪些分类为Google App Engine中的数据存储区写入操作?

时间:2011-11-13 17:36:46

标签: google-app-engine google-cloud-datastore

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

2 个答案:

答案 0 :(得分:17)

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

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

答案 1 :(得分:2)

请注意定价结构的变化 2016年7月1日per operation转为per entity。这会改变您对将有效(成本)写入数据存储的想法。

New Cloud Datastore Pricing Starting July 1st, 2016

  

2016年7月1日,Google Cloud Datastore定价将发生变化   按操作收费以按实体收费。这简单得多   定价意味着使用全部功率将大大降低成本   Google Cloud Datastore。

     

例如,在当前定价中,使用1编写新实体   索引属性将花费4次写入操作。在新的定价中,它   仅花费1个实体写入。同样,删除该实体   目前的定价将花费4次写入操作,但在新的定价中   它只需要1个实体删除。