AWS 對 DynamoDB 推出了 transaction 功能:「New – Amazon DynamoDB Transactions」。
這次推出的 transaction 還是很受限,不像是 RDBMS 裡那種可以到處讀讀寫寫然後到 SERIALIZABLE
等級的 ACID transaction。
目前提供兩種操作 TransactWriteItems 與 TransactGetItems:
- TransactWriteItems, a batch operation that contains a write set, with one or more PutItem, UpdateItem, and DeleteItem operations. TransactWriteItems can optionally check for prerequisite conditions that must be satisfied before making updates. These conditions may involve the same or different items than those in the write set. If any condition is not met, the transaction is rejected.
- TransactGetItems, a batch operation that contains a read set, with one or more GetItem operations. If a TransactGetItems request is issued on an item that is part of an active write transaction, the read transaction is canceled. To get the previously committed value, you can use a standard read.
主要是 TransactWriteItems 可以解決 ACID transaction 問題。而 TransactGetItems 算是搭配使用確保讀到的資料有一致性。
不過限制相當多,首先是修改數量的問題:
Each transaction can include up to 10 unique items or up to 4 MB of data, including conditions.
再來是限制同帳號且同區域 (這點應該還好):
DynamoDB transactions provide developers atomicity, consistency, isolation, and durability (ACID) across one or more tables within a single AWS account and region.
不管如何,這樣就更方便在上面堆東西了...