function enableCache($type, $connection, $cache_expire = 600, $table = 'flickr_cache') { $db = new SQLite3('flickr.db'); /* * If high performance is crucial, you can easily comment * out this query once you've created your database table. */ $db->query("\n\t\t\t\tCREATE TABLE IF NOT EXISTS `{$table}` (\n\t\t\t\t\t`request` CHAR( 35 ) NOT NULL ,\n\t\t\t\t\t`response` MEDIUMTEXT NOT NULL ,\n\t\t\t\t\t`expiration` DATETIME NOT NULL ,\n\t\t\t\t\tINDEX ( `request` )\n\t\t\t\t) TYPE = MYISAM"); if ($db->getOne("SELECT COUNT(*) FROM {$table}") > $this->max_cache_rows) { $db->query("DELETE FROM {$table} WHERE expiration < DATE_SUB(NOW(), INTERVAL {$cache_expire} second)"); $db->query('OPTIMIZE TABLE ' . $this->cache_table); } $this->cache = 'db'; $this->cache_db = $db; $this->cache_table = $table; $this->cache_expire = $cache_expire; }