Implement Cache for PmLicenseManager.
This commit is contained in:
David Callizaya
2017-09-01 15:53:30 -04:00
parent 6bd23225c6
commit 5d4a7edd12
2 changed files with 15 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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);
}