public function __construct(string $protocol = null) { if ($protocol !== null) { $this->mConnection = Database::newInstance($protocol); } else { $this->mConnection = Database::getInstance(); } if ($this->mConnection === null || !$this->mConnection->isConnected()) { throw new Exception("Could not connect to the database '{$protocol}'"); } if (mt_rand(0, 100) == 100) { $time = time(); $this->mConnection->delete("cache")->cond("cExpires", "i", time(), "<")->cond("cExpires", "i", 0, ">")->execute(); } }