public static function find($parameters = null) { //Create an unique key based on the parameters $key = self::_createKey($parameters); if (!isset(self::$_cache[$key])) { //Store the result in the memory cache self::$_cache[$key] = parent::find($parameters); } //Return the result in the cache return self::$_cache[$key]; }
public static function find($parameters = null) { //Convert the parameters to an array if (!is_array($parameters)) { $parameters = array($parameters); } //Check if a cache key wasn't passed //and create the cache parameters if (!isset($parameters['cache'])) { $parameters['cache'] = array("key" => self::_createKey($parameters), "lifetime" => 300); } return parent::find($parameters); }
public static function find($parameters = null) { //Create a unique key $key = self::_createKey($parameters); //Check if there are data in the cache $results = self::_getCache($key); // Valid data is an object if (is_object($results)) { return $results; } $results = array(); $invoices = parent::find($parameters); foreach ($invoices as $invoice) { //Query the related customer $customer = $invoice->customer; //Assign it to the record $invoice->customer = $customer; $results[] = $invoice; } //Store the invoices in the cache + their customers self::_setCache($key, $results); return $results; }
public static function find($parameters = null) { return parent::find($parameters); }