diff --git a/application/Device/Device.php b/application/Device/Device.php index 178f165fc..fa4186f27 100644 --- a/application/Device/Device.php +++ b/application/Device/Device.php @@ -15,25 +15,42 @@ class Device extends mfBaseModel return null; } - if ($name == "creator") { - $this->creator = new User($this->create_by); + if($name == "creator") { + $this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); + if($this->creator === null) { + $this->creator = new User($this->create_by); + if($this->creator->id) { + mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator); + } + } return $this->creator; } - if ($name == "editor") { - $this->editor = new User($this->edit_by); + if($name == "editor") { + $this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by); + if($this->editor === null) { + $this->editor = new User($this->edit_by); + if($this->editor->id) { + mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); + } + } return $this->editor; } $classname = ucfirst($name); - $idfield = $name . "_id"; - $this->$name = new $classname($this->$idfield); + $idfield = $name."_id"; + $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield); + if(!$this->$name) { + $this->$name = new $classname($this->$idfield); + } - if ($this->$name->id) { + if($this->$name->id) { + mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name); return $this->$name; } else { return null; } + } return $this->$name; diff --git a/application/Devicetype/Devicetype.php b/application/Devicetype/Devicetype.php index 7d8defcca..3e585bcec 100644 --- a/application/Devicetype/Devicetype.php +++ b/application/Devicetype/Devicetype.php @@ -15,24 +15,41 @@ class Devicetype extends mfBaseModel } if ($name == "creator") { - $this->creator = new User($this->create_by); + $this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by); + if ($this->creator === null) { + $this->creator = new User($this->create_by); + if ($this->creator->id) { + mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator); + } + } return $this->creator; } if ($name == "editor") { - $this->editor = new User($this->edit_by); + $this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by); + if ($this->editor === null) { + $this->editor = new User($this->edit_by); + if ($this->editor->id) { + mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor); + } + } return $this->editor; } $classname = ucfirst($name); $idfield = $name . "_id"; - $this->$name = new $classname($this->$idfield); + $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield); + if (!$this->$name) { + $this->$name = new $classname($this->$idfield); + } if ($this->$name->id) { + mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name); return $this->$name; } else { return null; } + } return $this->$name;