Skip to content

Commit

Permalink
DP-193 Added instance ID to configuration tab for easy reference
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgilmore committed Jun 10, 2020
1 parent ee9a093 commit e4390ac
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
12 changes: 2 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,8 @@
],
"authors": [
{
"name": "Arif Islam",
"email": "[email protected]"
},
{
"name": "Charles Harmon",
"email": "[email protected]"
},
{
"name": "Lee Hicks",
"email": "[email protected]"
"name": "DreamFactory Development Team",
"email": "[email protected]"
}
],
"support": {
Expand Down
17 changes: 17 additions & 0 deletions src/Models/InstanceId.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,21 @@ public static function generateInstanceId() {

return $model;
}

/**
* Returns InstanceId info cached, or reads from db if not present.
* Pass in an id.
*
* @return string|null
*/
public static function getCachedInstanceId()
{
$cacheKey = 'instance:id';
$result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'), function () {
return self::getInstanceIdOrGenerate();
});

return is_null($result) ? null : $result;
}

}
2 changes: 1 addition & 1 deletion src/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function stage()
*/
public function createApplication()
{
$app = require __DIR__ . '/../../../../../bootstrap/app.php';
$app = require '/opt/dreamfactory/bootstrap/app.php';

$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();

Expand Down
2 changes: 1 addition & 1 deletion src/Utility/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function getDreamFactoryInstanceId()
{
$instanceID = '';
try {
$instanceID = InstanceId::first()->instance_id;
$instanceID = InstanceId::getCachedInstanceId();
} catch (\Exception $e) {
$instanceID = "Not Found";
}
Expand Down

0 comments on commit e4390ac

Please sign in to comment.