问题
My current understanding of Google AppEngine's High Replication DataStore is the following:
Gets and puts of individual entities are always strongly consistent, i.e. once a put of this entry completes, no later get will ever return a version earlier than the completed put. Or, more precisely, as soon as any one get returns the new version, no later get will ever return the old version again.
Gets and puts of multiple entities are strongly consistent, if they belong to the same ancestor group and are performed in a transaction, i.e. if I have two entities that are both being modified in a transaction by a put and "simultaneously" read in a different transaction with a get, the get will either return the old version of both entries or the new version of both entries, depending on whether the put-transaction has completed at the time of the get or not, but it will never return the old value of one entity and the new value of the other.
Queries with an ancestor filter can be chosen to be strongly or eventually consistent, where a strongly consistent query takes longer to complete, but will always return the "same" version (old or new) of all entities updated in the same transaction in this ancestor group and never some old and some new versions.
Queries that span ancestors are always eventually consistent, i.e. might return an old version of one result entity and a new version of another.
Did I get this right? Is this actually documented anywhere? (I only found some documentation about the query consistency here (between the first and second "Note") and here, but it doesn't talk about gets and puts...)
回答1:
Yes, you're correct. They just word it slightly differently:
https://developers.google.com/appengine/docs/java/datastore/
Right at the beginning there are 5 point form features. The last two describe your question, except that they refer to "reads" instead of "gets".
This probably adds to your confusion, but when they mean "read" or "get", it really means fetching an entity directly - by key or id. If you call the python 'get' function with an attribute other than the key or id, it's actually issuing a query, which is eventually consistent (unless it's an ancestor query).
来源:https://stackoverflow.com/questions/18282395/google-appengine-datastore-constistency