EnzoAZHMHJ
New Member
I have this Two Methods\[code\]private function cacheAdd($id,$data){ $this->minicache->set($id,$data);}private function cacheGet($id){ return $this->minicache->get($id);}\[/code\]Each time if i want to check if the items are cached i have to do something like that:\[code\]public function getFriendIds() { $info = $this->cache->minicache->getInfo("getFriendIds"); // if its an array then it is cached if(is_array($info)) { return $this->cache->cacheGet("getFriendIds"); // return the cached object } // from here items wasnt cached else { $this->cache->cacheAdd("getFriendIds",$this->twitter->getFriendIds()); // so add to cache return $this->cache->cacheGet("getFriendIds"); // and return the cached items } }\[/code\]But i think there is a simple method to do this right?I thought something like this:\[code\]$this->cache->docache($this->myitems());\[/code\]and method docache takes just the method and converts the methodname to string and checks if the item is already cached or not How could that be done?EDIT:I implemented this docache method\[code\] public function docache($id,$data) { $info = $this->minicache->getInfo($id); if(is_array($info)) { return $this->cache->cacheGet($id); // return the cached object } else { $this->cacheAdd($id,$data); // so add to cache return $this->cacheGet($id); // and return the cached items } }\[/code\]and if i want to call the method i do this.\[code\] public function getFriendIds() { return $this->cache->docache("getFriendIds",$this->twitter->getFriendIds()); }\[/code\]No this is much smaller isnt it?