/** * Propagates revision last seen. * * @param string $path Path. * @param string $revision Revision. * * @return array */ protected function propagateRevisionLastSeen($path, $revision) { $to_update = array(); $update_path = $path; $select_sql = 'SELECT RevisionLastSeen FROM Paths WHERE PathHash = :path_hash'; $update_sql = 'UPDATE Paths SET RevisionLastSeen = :revision WHERE PathHash = :path_hash'; while (($update_path = dirname($update_path) . '/') !== '//') { $update_path_hash = $this->getPathChecksum($update_path); $fields_hash = $this->databaseCache->getFromCache('Paths', $update_path_hash . '/' . __METHOD__, $select_sql, array('path_hash' => $update_path_hash)); // Missing parent path. Can happen for example, when repository was created via "cvs2svn". if ($fields_hash === false) { $profiler = $this->database->getProfiler(); if ($profiler instanceof StatementProfiler) { $profiler->removeProfile($select_sql, array('path_hash' => $update_path_hash)); } break; } // TODO: Collect these paths and issue single update after cycle finishes. if ((int) $fields_hash['RevisionLastSeen'] < $revision) { $this->database->perform($update_sql, array('revision' => $revision, 'path_hash' => $update_path_hash)); $fields_hash = array('RevisionLastSeen' => $revision); $this->databaseCache->setIntoCache('Paths', $update_path_hash . '/' . __METHOD__, $fields_hash); $to_update[$update_path_hash] = $fields_hash; } } return $to_update; }
public function testClear() { $this->databaseCache->cacheTable('Tests'); $this->databaseCache->setIntoCache('Tests', 'key', array('aa' => 'bb')); $this->assertEquals(array('aa' => 'bb'), $this->databaseCache->getFromCache('Tests', 'key')); $this->databaseCache->clear(); $this->assertFalse($this->databaseCache->getFromCache('Tests', 'key'), 'All values were removed from cache.'); }
/** * Creates missing path. * * @param string $path Path. * @param string $ref_name Ref name. * @param string $project_path Project path. * @param integer $revision Revision. * @param string $action Action. * * @return integer */ protected function createMissingPath($path, $ref_name, $project_path, $revision, $action) { if (!isset($this->_pathsMap[$path])) { $this->_pathsMap[$path] = $this->_repositoryFiller->addPath($path, $ref_name, $project_path, $revision); } else { $sql = 'SELECT RevisionAdded, RevisionDeleted, RevisionLastSeen FROM Paths WHERE Id = :id'; $touch_path_data = $this->_databaseCache->getFromCache('Paths', $this->_repositoryFiller->getPathChecksum($path) . '/' . __METHOD__, $sql, array('id' => $this->_pathsMap[$path])); $touch_fields = $this->_repositoryFiller->getPathTouchFields($action, $revision, $touch_path_data); if ($touch_fields) { $touched_paths = $this->_repositoryFiller->touchPath($path, $revision, $touch_fields); foreach ($touched_paths as $touched_path_hash => $touched_path_fields_hash) { $path_data = $this->_databaseCache->getFromCache('Paths', $touched_path_hash . '/' . __METHOD__); if ($path_data !== false) { $this->_databaseCache->setIntoCache('Paths', $touched_path_hash . '/' . __METHOD__, $touched_path_fields_hash); } } } } return $this->_pathsMap[$path]; }
/** * Frees consumed memory. * * @return void * * @codeCoverageIgnore */ protected function freeMemoryManually() { parent::freeMemoryManually(); $this->_databaseCache->clear(); }