You are here

public function StaticCache::getExpiredFiles in Tome 8

Gets files that are in cache but invalid, and can be deleted.

The caller of this method must immediately act on or store returned expired files, as they are removed from cache storage after being returned.

Return value

array Files that have been expired.

Overrides StaticCacheInterface::getExpiredFiles

File

modules/tome_static/src/StaticCache.php, line 80

Class

StaticCache
Determines if pages are statically cached.

Namespace

Drupal\tome_static

Code

public function getExpiredFiles() {
  $this
    ->ensureBinExists();
  $cids = $this->connection
    ->select($this->bin)
    ->fields($this->bin, [
    'cid',
  ])
    ->execute()
    ->fetchCol();
  $files = [];
  foreach ($this
    ->getMultiple($cids, TRUE) as $cache) {
    if (!$cache->valid && file_exists($cache->data)) {
      $files[$cache->data] = $cache->data;
    }
  }
  parent::garbageCollection();
  return array_values($files);
}