Line 18 | Line 18 |
---|
*/ class service {
|
*/ class service {
|
| /** @var string Name of event used for cache purging */ private const PURGE_DEFERRED_ON_EVENT = 'core.garbage_collection';
/** @var bool Flag whether cache purge has been deferred */ private $cache_purge_deferred = false;
|
/** * Cache driver. *
| /** * Cache driver. *
|
Line 38 | Line 44 |
---|
* @var \phpbb\db\driver\driver_interface */ protected $db;
|
* @var \phpbb\db\driver\driver_interface */ protected $db;
|
| /** @var \phpbb\event\dispatcher phpBB Event dispatcher */ protected $dispatcher;
|
/** * Root path.
| /** * Root path.
|
Line 59 | Line 68 |
---|
* @param \phpbb\cache\driver\driver_interface $driver The cache driver * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver_interface $db Database connection
|
* @param \phpbb\cache\driver\driver_interface $driver The cache driver * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver_interface $db Database connection
|
| * @param \phpbb\event\dispatcher $dispatcher Event dispatcher
|
* @param string $phpbb_root_path Root path * @param string $php_ext PHP file extension */
|
* @param string $phpbb_root_path Root path * @param string $php_ext PHP file extension */
|
public function __construct(\phpbb\cache\driver\driver_interface $driver, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext)
| public function __construct(\phpbb\cache\driver\driver_interface $driver, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher $dispatcher, $phpbb_root_path, $php_ext)
|
{ $this->set_driver($driver); $this->config = $config; $this->db = $db;
|
{ $this->set_driver($driver); $this->config = $config; $this->db = $db;
|
| $this->dispatcher = $dispatcher;
|
$this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; }
| $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; }
|
Line 79 | Line 90 |
---|
public function get_driver() { return $this->driver;
|
public function get_driver() { return $this->driver;
|
| }
/** * Deferred purge of the cache. * * A deferred purge will be executed after rendering a page. * It is recommended to be used in cases where an instant purge of the cache * is not required, i.e. when the goal of a cache purge is to start from a * clear cache at the next page load. * * @return void */ public function deferred_purge(): void { if (!$this->cache_purge_deferred) { $this->dispatcher->addListener(self::PURGE_DEFERRED_ON_EVENT, [$this, 'purge']); $this->cache_purge_deferred = true; }
|
}
/**
| }
/**
|