/** * Construct cache from cache storage root * * @param string $root * @return void */ public function __construct($root) { parent::__construct($root); // Check for existance of meta data storage file if (!file_exists($storage = $this->root . '/cacheSize')) { file_put_contents($storage, '0'); } $this->storage = $storage; }
/** * Construct cache from cache storage root * * @param string $root * @return void */ public function __construct($root) { parent::__construct($root); // Check for existance of meta data storage file if (!file_exists($dbFile = $this->root . '/metadata.db')) { // Create cache directory, if not yet existing if (!is_dir($this->root)) { mkdir($this->root, 0750, true); } // Create the table with appropriate indexes, if the table does not // yet exist $db = new SQLite3($dbFile); $db->query('CREATE TABLE metadata ( path TEXT PRIMARY KEY, size NUMERIC, accessed NUMERIC )'); $db->query('CREATE INDEX size ON metadata ( size )'); $db->query('CREATE INDEX accessed ON metadata ( accessed )'); } $this->db = new SQLite3($dbFile); }