close #48 add multi DB object instance caching support
This commit is contained in:
@@ -71,16 +71,18 @@ class Route extends \Controller\AccessController {
|
||||
$this->f3->exists($cacheKeyIdArray)
|
||||
){
|
||||
// get cached values
|
||||
|
||||
$this->nameArray = $this->f3->get($cacheKeyNamedArray);
|
||||
$this->jumpArray = $this->f3->get($cacheKeyJumpArray);
|
||||
$this->idArray = $this->f3->get($cacheKeyIdArray);
|
||||
}else{
|
||||
// nothing cached
|
||||
|
||||
$pfDB = $this->getDB('PF');
|
||||
|
||||
$query = "SELECT * FROM system_neighbour";
|
||||
|
||||
$rows = $this->f3->get('DB')->exec($query, null, $this->jumpDataCacheTime);
|
||||
|
||||
$rows = $pfDB->exec($query, null, $this->jumpDataCacheTime);
|
||||
|
||||
foreach($rows as $row){
|
||||
$regionId = $row['regionId'];
|
||||
@@ -202,8 +204,8 @@ class Route extends \Controller\AccessController {
|
||||
*/
|
||||
private function setupSystemJumpTable(){
|
||||
|
||||
// switch DB
|
||||
$this->setDB('CCP');
|
||||
$pfDB = $this->getDB('PF');
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
|
||||
$query = "SELECT
|
||||
map_sys.solarSystemID system_id,
|
||||
@@ -228,18 +230,17 @@ class Route extends \Controller\AccessController {
|
||||
system_neighbours IS NOT NULL
|
||||
";
|
||||
|
||||
$rows = $this->f3->get('DB')->exec($query);
|
||||
$rows = $ccpDB->exec($query);
|
||||
|
||||
if(count($rows) > 0){
|
||||
// switch DB back to pathfinder DB
|
||||
$this->setDB('PF');
|
||||
|
||||
// clear cache table
|
||||
$query = "TRUNCATE system_neighbour";
|
||||
$this->f3->get('DB')->exec($query);
|
||||
$pfDB->exec($query);
|
||||
|
||||
foreach($rows as $row){
|
||||
$this->f3->get('DB')->exec("
|
||||
$pfDB->exec("
|
||||
INSERT INTO
|
||||
system_neighbour(
|
||||
regionId,
|
||||
|
||||
@@ -99,24 +99,20 @@ class System extends \Controller\AccessController {
|
||||
|
||||
$systemModels = [];
|
||||
|
||||
// switch DB
|
||||
$this->setDB('CCP');
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
|
||||
$this->whereQuery = "WHERE
|
||||
map_sys." . $column . " IN (" . implode(',', $columnIDs) . ")";
|
||||
|
||||
$query = $this->_getQuery();
|
||||
|
||||
$rows = $this->f3->get('DB')->exec($query, null, 60 * 60 * 24);
|
||||
$rows = $ccpDB->exec($query, null, 60 * 60 * 24);
|
||||
|
||||
// format result
|
||||
$mapper = new Mapper\CcpSystemsMapper($rows);
|
||||
|
||||
$ccpSystemsData = $mapper->getData();
|
||||
|
||||
// switch DB
|
||||
$this->setDB('PF');
|
||||
|
||||
foreach($ccpSystemsData as $ccpSystemData){
|
||||
$system = Model\BasicModel::getNew('SystemModel');
|
||||
$system->setData($ccpSystemData);
|
||||
@@ -132,12 +128,11 @@ class System extends \Controller\AccessController {
|
||||
*/
|
||||
public function getSystems(){
|
||||
|
||||
// switch DB
|
||||
$this->setDB('CCP');
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
|
||||
$query = $this->_getQuery();
|
||||
|
||||
$rows = $this->f3->get('DB')->exec($query, null, 60 * 60 * 24);
|
||||
$rows = $ccpDB->exec($query, null, 60 * 60 * 24);
|
||||
|
||||
// format result
|
||||
$mapper = new Mapper\CcpSystemsMapper($rows);
|
||||
@@ -152,9 +147,7 @@ class System extends \Controller\AccessController {
|
||||
*/
|
||||
public function search($f3, $params){
|
||||
|
||||
// switch DB
|
||||
\DB\Database::instance();
|
||||
$this->setDB('CCP');
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
|
||||
$searchToken = '';
|
||||
// check for search parameter
|
||||
@@ -167,7 +160,7 @@ class System extends \Controller\AccessController {
|
||||
|
||||
$query = $this->_getQuery();
|
||||
|
||||
$rows = $f3->get('DB')->exec($query);
|
||||
$rows = $ccpDB->exec($query);
|
||||
|
||||
// format result
|
||||
$mapper = new Mapper\CcpSystemsMapper($rows);
|
||||
|
||||
Reference in New Issue
Block a user