System Overview - Transaction history
This system records and retrieves users' transaction histories. It must handle many users making transactions simultaneously and allow quick access to past transactions.
Jump into concepts and practice - no test required
This system records and retrieves users' transaction histories. It must handle many users making transactions simultaneously and allow quick access to past transactions.
User | v Load Balancer | v API Gateway | v Transaction Service | +--> Cache | v Database
transaction history in a system?transactions = [
{"id": "t1", "time": "2024-01-01T10:00:00Z"},
{"id": "t2", "time": "2024-01-01T09:00:00Z"},
{"id": "t3", "time": "2024-01-01T11:00:00Z"}
]def add_transaction(history, transaction):
if transaction['id'] not in [t['id'] for t in history]:
history.append(transaction)
else:
print("Duplicate transaction")
history = [{"id": "t1"}]
add_transaction(history, {"id": "t1"})