diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-02-25 21:35:11 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-07-21 23:17:36 +0200 |
commit | a48e9c488b7ccf22a911a0fb33b69ef782f63a81 (patch) | |
tree | cc7f3ebb26fc26efa62cbff253e4f50b80ef5ba8 /lib/db.php | |
parent | e3c5fea989f26a4ad16b841be25ea485c8aad8c4 (diff) | |
download | nextcloud-server-a48e9c488b7ccf22a911a0fb33b69ef782f63a81.tar.gz nextcloud-server-a48e9c488b7ccf22a911a0fb33b69ef782f63a81.zip |
Move prepared query cache handling to Connection wrapper
Diffstat (limited to 'lib/db.php')
-rw-r--r-- | lib/db.php | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/lib/db.php b/lib/db.php index c1c419df545..c5690bdd8a9 100644 --- a/lib/db.php +++ b/lib/db.php @@ -43,9 +43,6 @@ class DatabaseException extends Exception { class OC_DB { const BACKEND_DOCTRINE=2; - static private $preparedQueries = array(); - static private $cachingEnabled = true; - /** * @var \Doctrine\DBAL\Connection */ @@ -102,7 +99,6 @@ class OC_DB { return true; } } - self::$preparedQueries = array(); // The global data we need $name = OC_Config::getValue( "dbname", "owncloud" ); $host = OC_Config::getValue( "dbhost", "" ); @@ -186,6 +182,11 @@ class OC_DB { $connectionParams['table_prefix'] = OC_Config::getValue( "dbtableprefix", "oc_" ); try { self::$DOCTRINE = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config); + if ($type === 'sqlite' || $type === 'sqlite3') { + // Sqlite doesn't handle query caching and schema changes + // TODO: find a better way to handle this + self::$connection->disableQueryStatementCaching(); + } } catch(\Doctrine\DBAL\DBALException $e) { OC_Log::write('core', $e->getMessage(), OC_Log::FATAL); OC_User::setUserId(null); @@ -219,12 +220,8 @@ class OC_DB { } $platform = self::$connection->getDatabasePlatform(); $query = $platform->modifyLimitQuery($query, $limit, $offset); - } else { - if (isset(self::$preparedQueries[$query]) and self::$cachingEnabled) { - return self::$preparedQueries[$query]; } } - $rawQuery = $query; // Optimize the query $query = self::processQuery( $query ); @@ -248,12 +245,6 @@ class OC_DB { // differentiate between query and manipulation $result=new OC_DB_StatementWrapper($result, $isManipulation); } - if ((is_null($limit) || $limit == -1) and self::$cachingEnabled ) { - $type = OC_Config::getValue( "dbtype", "sqlite" ); - if( $type != 'sqlite' && $type != 'sqlite3' ) { - self::$preparedQueries[$rawQuery] = $result; - } - } return $result; } @@ -358,7 +349,6 @@ class OC_DB { // Cut connection if required if(self::$connection) { self::$connection->close(); - self::$preparedQueries = array(); } return true; @@ -672,9 +662,10 @@ class OC_DB { * @param bool $enabled */ static public function enableCaching($enabled) { - if (!$enabled) { - self::$preparedQueries = array(); + if ($enabled) { + self::$connection->enableQueryStatementCaching(); + } else { + self::$connection->disableQueryStatementCaching(); } - self::$cachingEnabled = $enabled; } } |