HOR-3825
Implement Cache for PmLicenseManager.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
<?php
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class PMLicensedFeatures
|
||||
{
|
||||
|
||||
private $featuresDetails = array ();
|
||||
private $features = array ();
|
||||
private $newFeatures = array(
|
||||
@@ -334,6 +337,11 @@ class PMLicensedFeatures
|
||||
/*----------------------------------********---------------------------------*/
|
||||
public function verifyfeature ($featureName)
|
||||
{
|
||||
$cached = Cache::get(PmLicenseManager::CACHE_KEY . '.' . SYS_SYS, []);
|
||||
if (isset($cached[$featureName])) {
|
||||
return $cached[$featureName];
|
||||
}
|
||||
|
||||
$licenseManager = PmLicenseManager::getSingleton(false);
|
||||
|
||||
$_SESSION['__sw__'] = true;
|
||||
@@ -350,6 +358,10 @@ class PMLicensedFeatures
|
||||
$this->featuresDetails[$value[0]] = new stdclass();
|
||||
}
|
||||
$this->featuresDetails[$value[0]]->enabled = $enable;
|
||||
|
||||
$cached[$featureName] = $enable;
|
||||
Cache::put(PmLicenseManager::CACHE_KEY . '.' . SYS_SYS, $cached, Carbon::now()->addDay(1));
|
||||
|
||||
return $enable;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
/**
|
||||
* class.pmLicenseManager.php
|
||||
@@ -10,6 +10,7 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
class PmLicenseManager
|
||||
{
|
||||
const CACHE_KEY = 'license';
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
@@ -474,6 +475,7 @@ class PmLicenseManager
|
||||
$tr->setLicenseType ( $LicenseType );
|
||||
|
||||
$res = $tr->save ();
|
||||
Cache::forget(PmLicenseManager::CACHE_KEY . '.' . SYS_SYS);
|
||||
} catch ( Exception $e ) {
|
||||
G::pr($e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user