function PerformanceTestTrait::isDatabaseCache

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/PerformanceTestTrait.php \Drupal\Tests\PerformanceTestTrait::isDatabaseCache()

Checks whether a database event is from the database cache implementation.

Parameters

Drupal\Core\Database\Event\DatabaseEvent $event: The database event.

Return value

bool Whether the event was triggered by the database cache implementation.

2 calls to PerformanceTestTrait::isDatabaseCache()
PerformanceTestTrait::collectPerformanceData in core/tests/Drupal/Tests/PerformanceTestTrait.php
Executes a callable and collects performance data.
PerformanceTestTrait::openTelemetryTracing in core/tests/Drupal/Tests/PerformanceTestTrait.php
Sends metrics to OpenTelemetry.

File

core/tests/Drupal/Tests/PerformanceTestTrait.php, line 616

Class

PerformanceTestTrait
Provides various methods to aid in collecting performance data during tests.

Namespace

Drupal\Tests

Code

protected static function isDatabaseCache(DatabaseEvent $event) : bool {
    // If there is no class, then this is called from a procedural function.
    if (isset($event->caller['class'])) {
        $class = str_replace('\\\\', '\\', $event->caller['class']);
        return is_a($class, '\\Drupal\\Core\\Cache\\DatabaseBackend', TRUE) || is_a($class, '\\Drupal\\Core\\Cache\\DatabaseCacheTagsChecksum', TRUE);
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.