Added simple caching to Termination and Building workflow
This commit is contained in:
@@ -80,9 +80,13 @@ class Building extends mfBaseModel {
|
||||
}
|
||||
|
||||
public function getWorkflowvalue($itemname, $type = false) {
|
||||
$item = WorkflowitemModel::getFirst(['name' => $itemname]);
|
||||
if(!$item->id) {
|
||||
return null;
|
||||
$item = mfValuecache::get("wfBuilding-".$itemname);
|
||||
if(!$item) {
|
||||
$item = WorkflowitemModel::getFirst(['name' => $itemname]);
|
||||
if(!$item->id) {
|
||||
return null;
|
||||
}
|
||||
mfValuecache::set("wfBuilding-".$itemname, $item);
|
||||
}
|
||||
|
||||
switch($item->type) {
|
||||
|
||||
@@ -36,9 +36,13 @@ class Termination extends mfBaseModel {
|
||||
}
|
||||
|
||||
public function getWorkflowvalue($itemname, $type = false) {
|
||||
$item = WorkflowitemModel::getFirst(['name' => $itemname]);
|
||||
if(!$item->id) {
|
||||
return null;
|
||||
$item = mfValuecache::get("wfTerm-".$itemname);
|
||||
if(!$item) {
|
||||
$item = WorkflowitemModel::getFirst(['name' => $itemname]);
|
||||
if(!$item->id) {
|
||||
return null;
|
||||
}
|
||||
mfValuecache::set("wfTerm-".$itemname, $item);
|
||||
}
|
||||
|
||||
switch($item->type) {
|
||||
|
||||
32
lib/mvcfronk/mfValuecache/mfValuecache.php
Normal file
32
lib/mvcfronk/mfValuecache/mfValuecache.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class mfValuecache {
|
||||
public static $instance;
|
||||
private $cache;
|
||||
|
||||
|
||||
private function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public static function singleton() {
|
||||
if(!isset(self::$instance)) {
|
||||
$c=__CLASS__;
|
||||
self::$instance=new $c();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public static function get($key) {
|
||||
$instance = self::singleton();
|
||||
if(array_key_exists($key, $instance->cache)) {
|
||||
return $instance->cache[$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function set($key, $value) {
|
||||
$instance = self::singleton();
|
||||
$instance->cache[$key] = $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user