4
兩個代碼示例(簡化的):該事務AppEngine Transaction是否需要執行get和put操作才能使其有用?
@db.transactional
def update_object2_txn(obj_key, new_value):
obj = db.get(obj_key)
obj.prop1 = new_value
return obj.put()
內部
。獲得的事務之外(對象從。獲得傳遞到事務性功能)
@db.transactional
def update_object_1_txn(obj, new_value):
obj.prop1 = new_value
return obj.put()
。獲得
第一個例子合乎邏輯嗎?那裏的交易有用嗎?它提供了什麼?我試圖更好地瞭解appengine的交易。選擇第二個選項會阻止該對象的併發修改嗎?
真棒,謝謝。很好的答案! – computmaxer