Google 将什么分类为 Google App Engine 中的数据存储写入操作?
自从 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要支付的写入次数取决于您的实体。一般来说,您需要为实体的 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.
请注意,定价结构的变化将于2016 年 7 月 1 日生效,从
按操作
更改为按实体
。这改变了您对高效(从成本角度)写入数据存储的看法。新的云数据存储区定价将于 2016 年 7 月 1 日开始
Note the changes in pricing structure going into effect July 1st, 2016 going from
per operation
toper entity
. This changes how you think about writing efficiently (cost-wise) to Datastore.New Cloud Datastore Pricing Starting July 1st, 2016