Revision: 28101
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 30, 2010 22:25 by orenus
Initial Code
//performance tuning...
class WeatherService{
private $cache;
public function WeatherService(){
//some initialization...
$cache = new MemCache();
}
public function getWeatherInfo($city, $method){
if ($cache->get()[$city])
return $cache->get($city);
$res = shell_exec("./getWdr.sh {$city}");
$this->cache->set($city,$res);
if ($methos=="CL")
return convertFrToC($res);
return $res;
}
private function convertFrToC($val){
return (($val+40)*5/9)-40;
}
}
class MemCache{
private $mem;
public function MemCache(){
//some intitialization here...
$mem = array();
}
public function get(){
return $this->mem;
}
public function set($key, $val){
echo "putting [$val] in $key";
$this->mem[$key] = $val;
}
}
Initial URL
Initial Description
Initial Title
Get Weather - Step 5 - Improving performance
Initial Tags
php
Initial Language
PHP