获取天气-步骤5-提高性能
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取天气-步骤5-提高性能相关的知识,希望对你有一定的参考价值。
//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); $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... } public function get(){ return $this->mem; } public function set($key, $val){ echo "putting [$val] in $key"; $this->mem[$key] = $val; } }
以上是关于获取天气-步骤5-提高性能的主要内容,如果未能解决你的问题,请参考以下文章