Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TransactionManagerInterface.php

function TransactionManagerInterface::addPostTransactionCallback

Adds a root transaction end callback.

These callbacks are invoked immediately after the client transaction has been committed or rolled back.

It can for example be used to avoid deadlocks on write-heavy tables that do not need to be part of the transaction, like cache tag invalidations.

Another use case is that services using alternative backends like Redis and Memcache cache implementations can replicate the transaction-behavior of the database cache backend and avoid race conditions.

An argument is passed to the callbacks that indicates whether the transaction was successful or not.

Parameters

callable $callback: The callback to invoke.

Throws

\LogicException When a callback addition is attempted but no transaction is active.

1 method overrides TransactionManagerInterface::addPostTransactionCallback()
TransactionManagerBase::addPostTransactionCallback in core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php
Adds a root transaction end callback.

File

core/lib/Drupal/Core/Database/Transaction/TransactionManagerInterface.php, line 133

Class

TransactionManagerInterface
Interface for the database transaction manager classes.

Namespace

Drupal\Core\Database\Transaction

Code

public function addPostTransactionCallback(callable $callback) : void;
RSS feed
Powered by Drupal