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

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

问题描述

由于GAE在上周初进入定价模式,我一直在努力超越配额的数据存储读写操作。我不确定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天全站免登陆