3 ms·
This is actually a great advice - but not all operations can be made idempotent. Adding and substracting money from bank accounts comes to mind (although you ca
by annnnd 12y ago
This is actually a great advice - but not all operations can be made idempotent. Adding and substracting money from bank accounts comes to mind (although you can make the operation "write transaction to some log" idempotent, you can't perform the actual computations in an idempotent fashion).
- electrum 12y agoYou handle this by modeling the account as a ledger with immutable entries containing unique identifiers rather than a single mutable balance. The ledger entries are facts. The balance is a derived computation. Only store facts, not derived computations. (At some point for efficiency reasons you might need to prune the transactions, but this often involves trade-offs like not allowing any new "lost" transactions older than date X.)
- deleted 12y ago[deleted]