祖先查询的写入限制是什么意思?

时间:2014-04-05 12:36:42

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

根据文档,使用ancestor queries时,将强制执行以下限制:

  

祖先查询允许您对该查询进行强一致性查询   数据存储区,但具有相同祖先的实体限制为1   每秒写一次。

class Customer(ndb.Model):
    name = ndb.StringProperty()

class Purchase(ndb.Model):
    price = ndb.IntegerProperty

purchase1 = Purchase(ancestor=customer_entity.key)
purchase2 = Purchase(ancestor=customer_entity.key)
purchase3 = Purchase(ancestor=customer_entity.key)

purchase1.put()
purchase2.put()
purchase3.put()

举个相同的例子,如果我要同时写三次购买,我会得到一个例外,因为它不到一秒钟吗?

1 个答案:

答案 0 :(得分:2)

在这里,您可以找到两个关于数据存储,强一致性和实体组的优秀视频。 Datastore IntroductionDatastore Query, Index and Transaction

关于你的例子。您可以使用put_multi()对单个实体组进行“计数”。