Bar*_*ine 9 google-app-engine google-cloud-datastore
由于GAE在上周初进入定价模型,我一直在努力超越我的Datastore读写操作配额.我不确定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);
}
}
Run Code Online (Sandbox Code Playgroud)
Nic*_*son 17
您收取的写入次数取决于您的实体.通常,您需要为实体收取1次写入费用,并为每次索引更新收取1次写入费用.每个索引属性都包含在升序和降序单属性索引中,因此每个索引实体至少有2次写入,以及复合(用户定义)索引的任何写入.
更新现有实体时,您需要为旧索引和新索引的差异付费.因此,如果您修改一个属性,您将需要为实体写入付费,并为内置索引的每个属性加上4个写入(删除旧值并插入新值),对于任何复合索引也是如此.
| 归档时间: |
|
| 查看次数: |
3038 次 |
| 最近记录: |