OK, first of all implicit transactions as you said work for both DO storage backends, no argument th

OK, first of all implicit transactions as you said work for both DO storage backends, no argument there.

Once any storage operation is used (even if not explicitly awaited) then an implicit transaction can be assumed. This transaction will include all storage operations until the next await for IO (e.g.
fetch
, including an explicitly awaited storage operation too, so any await doing remote stuff).

Example 1:
storage.put("ka", "va")
const f = fetch("externalURL"); // no await
storage.put("kb", "vb")

await f;

The two puts here are coalesced into a single transaction, which either succeeds or fails as a whole. If it fails, the fetch is blocked, since the first put() came before the fetch() started. Because the storage operation was before the creation of the fetch, there is implicit storage transaction and the fetch is blocked by the output gate.

Example 2:
const f = fetch("externalURL"); // no await
storage.put("ka", "va")
storage.put("kb", "vb")

await f;

Here, the fetch will start before the writes, since there is no storage operation till that moment and therefore no output gate involved. Then, the two puts are going to be in the same implicit transaction since there is no await between them.

So, I guess to simplify reasoning is that you group your storage operations in clusters between awaited calls. And those storage operations will be part of the same transaction. The key aspect of the storage operations is when they are called, not necessarily awaited due to the use of "cache" and output gates.
Was this page helpful?