Performance optimizations
This commit is contained in:
@@ -37,14 +37,25 @@ class Termination extends mfBaseModel {
|
||||
|
||||
public function loadWorkflowItems() {
|
||||
$item_ids = [];
|
||||
foreach(WorkflowitemModel::search(["object_type" => "Termination", "active" => 1]) as $item) {
|
||||
|
||||
$term_wfitems = mfValuecache::singleton()->get("wfitems-term-active");
|
||||
if(!$term_wfitems) {
|
||||
$term_wfitems = WorkflowitemModel::search(["object_type" => "Termination", "active" => 1]);
|
||||
mfValuecache::singleton()->set("wfitems-term-active", $term_wfitems);
|
||||
}
|
||||
|
||||
foreach($term_wfitems as $item) {
|
||||
$item->setObjectId($this->id);
|
||||
$this->workflowitems[$item->name] = $item;
|
||||
//mfValuecache::set("wfTerm-name-".$item->name, $item);
|
||||
//mfValuecache::set("wfTerm-id-".$item->id, $item);
|
||||
mfValuecache::singleton()->set("wfTerm-name-".$item->name, $item);
|
||||
mfValuecache::singleton()->set("wfTerm-id-".$item->id, $item);
|
||||
$item_ids[] = $item->id;
|
||||
}
|
||||
|
||||
foreach($item_ids as $id) {
|
||||
mfValuecache::singleton()->set("wfItemvalue-item-".$id."-object-".$this->id, new Workflowvalue());
|
||||
}
|
||||
|
||||
// get values
|
||||
$values = WorkflowvalueModel::search(["object_id" => $this->id]);
|
||||
//var_dump($values);exit;
|
||||
@@ -52,13 +63,13 @@ class Termination extends mfBaseModel {
|
||||
if(array_key_exists($value->item->name, $this->workflowitems)) {
|
||||
//var_dump($value);exit;
|
||||
$this->workflowitems[$value->item->name]->setValue($value);
|
||||
mfValuecache::singleton()->set("wfTerm-name-".$this->workflowitems[$value->item->name]->name, $this->workflowitems[$value->item->name]);
|
||||
mfValuecache::singleton()->set("wfTerm-id-".$this->workflowitems[$value->item->name]->id, $this->workflowitems[$value->item->name]);
|
||||
mfValuecache::singleton()->set("wfItemvalue-item-".$value->item_id."-object-".$value->object_id, $value);
|
||||
mfValuecache::singleton()->set("wfItemvalue-item-".$value->item_id."-object-".$this->id, $value);
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump(array_keys(mfValuecache::singleton()->getCache()));
|
||||
/*if($this->id == 42) {
|
||||
//var_dump(array_keys(mfValuecache::singleton()->getCache()));exit;
|
||||
var_dump(mfValuecache::singleton()->get("wfItemvalue-item-20-object-42"));exit;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,14 @@ class Workflowitem extends mfBaseModel {
|
||||
return $value;
|
||||
}
|
||||
$value = WorkflowvalueModel::getFirst(['item_id' => $this->id, "object_id" => $this->object_id]);
|
||||
// explicitly cache empty value
|
||||
mfValuecache::singleton()->set("wfItemvalue-item-".$this->id."-object-".$this->object_id, $value);
|
||||
if(!$value) {
|
||||
$vdata['item_id'] = $this->id;
|
||||
$vdata['object_id'] = $this->object_id;
|
||||
$value = WorkflowvalueModel::create($vdata);
|
||||
|
||||
}
|
||||
mfValuecache::singleton()->set("wfItemvalue-item-".$this->id."-object-".$this->object_id, $value);
|
||||
$this->value = $value;
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user