In the Google App Engine, how can I work with possible consistency when processing forms?

I noticed that with constant consistency, the general form processing workflow that I use (submit -> create / update record -> redirect -> reload) doesn't work. When forwarding, a new entry (possibly) will not be available for display. How do I handle forms so that updates appear on reboot?

I could try using strong consistency, but as noted in the App Engine note , updates are limited to one update per second .

So, how can I process a form that provides immediate feedback with the final consistency?

+4
source share
2 answers

Try rebuilding your code so that you get the key (which always gives you the latest data) instead of executing the request. I understand that this is not always possible, but I will give you a recent example of what worked for me.

I have a custom panel where the user can create and delete "items". My objects looked like this:

class User(ndb.Model)
    ...

class Item(ndb.Model)
    user = ndb.KeyProperty(User, required=True)

In the past, I made such a request when I answered a GET request for a custom dashboard.

items = Item.query(user=user.key)

, , , POST/redirect/GET - .

, User :

class User(ndb.Model)
    items = ndb.KeyProperty(repeated=True)
    ...

, , :

items = ndb.get_multi(user.items)

, .

, . , , - .

+4

, , . , .

, Google ( "Paxos" ) ( , - - - . ).

:

, , . , :

... [ ]...

  • . , Datastore .

, , , , , , .

, - , .

, , .

. " " .

+3

Source: https://habr.com/ru/post/1624498/


All Articles