class BoostCache in Boost 8
The BoostCache class.
@todo, only fire notices if debug (mode) enabled. @todo, batch to generate entire cache. @todo, cron to re-generate/ invalidate cache. @todo, exclude route list, don't cache specific paths.
Hierarchy
- class \Drupal\boost\BoostCache
Expanded class hierarchy of BoostCache
1 file declares its use of BoostCache
- BoostResponseSubscriber.php in src/
EventSubscriber/ BoostResponseSubscriber.php - Contains Drupal\boost\EventSubscriber\BoostResponseSubscriber
File
- src/
BoostCache.php, line 21 - Contains Drupal\boost\BoostCache
Namespace
Drupal\boostView source
class BoostCache {
/**
* @var \Drupal\boost\BoostCacheHandler
*/
protected $handler;
/**
* @var \Drupal\boost\BoostCacheRoute
*/
protected $route;
/**
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs a new BoostCache.
*/
public function __construct() {
$this->handler = new BoostCacheHandler();
$this->route = new BoostCacheRoute(\Drupal::service('path.current'), \Drupal::service('path.alias_manager'));
$this->logger = \Drupal::logger('boost');
}
/**
* Save page to local filesystem.
* @param string $response
*
* @todo, _toString if Symfony Response.
*/
public function index($response) {
if (!is_string($response)) {
$this->logger
->notice('Response for route @uri can not be cached.', array(
'@uri' => $this->route
->getPath(),
));
return;
}
$this->handler
->setCache($this->route
->getUri(), $response);
}
/**
* Retrieve Boost cache file.
*/
public function retrieve() {
$uri = $this->route
->getUri();
if (!file_exists($uri)) {
$this->logger
->notice('Route @uri not cached.', array(
'@uri' => $uri,
));
return false;
}
return $this->handler
->getCache($uri);
}
/**
* Delete individual cache file.
*/
public function delete() {
$uri = $this->route
->getUri();
if (!file_exists($uri)) {
return false;
}
return $this->handler
->deleteCache($uri);
}
/**
* Delete entire boost cache.
*/
public function purge() {
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BoostCache:: |
protected | property | ||
BoostCache:: |
protected | property | ||
BoostCache:: |
protected | property | ||
BoostCache:: |
public | function | Delete individual cache file. | |
BoostCache:: |
public | function | Save page to local filesystem. | |
BoostCache:: |
public | function | Delete entire boost cache. | |
BoostCache:: |
public | function | Retrieve Boost cache file. | |
BoostCache:: |
public | function | Constructs a new BoostCache. |