Exemple #1
0
 /**
  * @return bool
  * @throws StorageException
  */
 public function flush() : bool
 {
     $flush = $this->db->query(sprintf('DELETE FROM `%1$s`', self::SCHEMA_TABLE), [], \Comely\IO\Database\Database::QUERY_EXEC);
     if (!$flush || !$this->db->lastQuery->rows) {
         $error = $this->db->lastQuery->error ?? sprintf('Flushed %d files', $this->db->lastQuery->rows);
         throw StorageException::flushError(__METHOD__, $error);
     }
     return true;
 }
Exemple #2
0
 /**
  * @return bool
  * @throws StorageException
  */
 public function flush() : bool
 {
     $flush = $this->cache->flush();
     if (!$flush) {
         $error = !empty($this->cache->lastError()) ? $this->cache->lastError() : 'Failed';
         throw StorageException::flushError(__METHOD__, $error);
     }
     return true;
 }
Exemple #3
0
 /**
  * @return bool
  * @throws StorageException
  */
 public function flush() : bool
 {
     $files = $this->disk->find("*.sess");
     $count = 0;
     foreach ($files as $file) {
         try {
             $this->disk->delete($file);
             $count++;
         } catch (FilesystemException $e) {
         }
     }
     if (!$count) {
         throw StorageException::flushError(__METHOD__, sprintf('Flushed %d files', $count));
     }
     return true;
 }