AfterCommit
AfterCommit is a term used to describe a lifecycle hook in some persistence frameworks that runs only after a surrounding database transaction has been successfully committed. The purpose is to perform actions that should occur only when data changes are durable, avoiding side effects if the transaction is rolled back. This timing distinction helps ensure data integrity for subsequent operations such as notifications, cache updates, or background job scheduling.
In the Ruby on Rails ecosystem, the equivalent concept appears as after_commit, a callback provided by ActiveRecord.
Common use cases for afterCommit include enqueuing background jobs, publishing domain events to message brokers, or
Notes and caveats include the fact that afterCommit only fires when the transaction commits, not when it