是否可以强制 GAE 数据存储的强一致性?
我有这个代码:
#!/usr/bin/env python
Import OS, says
import wsgiref.handlers
import webapp2
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
class guestbook(db.Model):
message = db.StringProperty(required=True)
when = db.DateTimeProperty(auto_now_add=True)
who = db.StringProperty()
class ShowGuestbookPage(webapp2.RequestHandler):
def get(self):
# Read from the Datastore
shouts = db.GqlQuery('SELECT * FROM guestbook ORDER BY when DESC')
values = {'shouts': shouts}
self.response.out.write(template.render('main.html', values))
class MakeGuestbookEntry(webapp2.RequestHandler):
def post(self):
shout = guestbook(message=self.request.get('message'), who=self.request.get('who'))
# Write into the datastore
shout.put()
self.redirect('/')
app = webapp2.WSGIApplication([('/', ShowGuestbookPage),
('/make_entry', MakeGuestbookEntry),
debug=True)
def main():
run_wsgi_app(app)
if __name__ == "__main__":
main()
实现强一致性的最简单方法是什么?
我不明白如何将 Google 的解释 [1] 翻译成源代码。
[1] https://developers.google.com/appengine/docs/java/datastore/structuring_for_strong_consistency
谢谢你的帮助。