GoogleCloudPlatform / datastore-ndb-python

Client library for use with Google Cloud Datastore from within the Google App Engine Python runtime.
https://cloud.google.com/appengine/docs/standard/python/ndb/
Apache License 2.0
114 stars 48 forks source link

NDB put is working async #285

Closed kautilya-pro closed 6 years ago

kautilya-pro commented 7 years ago

when I'm putting a new entity in ndb table and counting the number of all entities in the table. I'm getting one number lesser than what actually should be. The put() is working asynchronously. Then, what's the difference between put() and put_async()?

kolinko commented 6 years ago

You might want to read about strong and eventual consistency. Regular put is synchronous, but the db change may have not arrived in the database yet for reading.

wsh commented 6 years ago

@kautilya-pro: assuming that by table you mean kind, the query you describe is a global query. As this article on consistency in Cloud Datastore notes:

Global queries (those that do not execute against an entity group) are always eventually consistent.