-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrupal_cache_protection.module
More file actions
46 lines (42 loc) · 1.23 KB
/
drupal_cache_protection.module
File metadata and controls
46 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* @file
* Drupal Cache Protection — runtime hooks.
*
* The Warmer subsystem hooks rebuild + cron here; other concerns (the
* tracking-param middleware, settings form) are wired up via services
* and routing and don't need procedural hooks.
*
* Hook bodies catch Throwable so a warmer fault never propagates out
* of a cache flush or cron tick. Diagnostic state is surfaced via
* hook_requirements() rather than the watchdog log.
*/
declare(strict_types=1);
/**
* Implements hook_rebuild().
*
* Fires at the end of drupal_flush_all_caches(). Delegates the warm to
* the current warmer strategy, which decides how to defer the actual
* work (post-response, detached drush spawn, or inline).
*/
function drupal_cache_protection_rebuild(): void {
try {
\Drupal::service('drupal_cache_protection.warmer')->warm();
}
catch (\Throwable) {
}
}
/**
* Implements hook_cron().
*
* Drives the asynchronous survival probe: spawns on the appropriate
* cron tick, checks pending results on the next tick, updates the
* persisted strategy selection in response.
*/
function drupal_cache_protection_cron(): void {
try {
\Drupal::service('drupal_cache_protection.warmer')->maintainProbe();
}
catch (\Throwable) {
}
}