Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'advanced php programming- p7', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 278 Chapter 10 Data Component Caching php function generate_navigation tag list topic subtopic explode 1 - 1 tag 2 if function_exists generate_navigation_ topic return call_user_func generate_navigation_ topic subtopic else return unknown A generation function for a project summary looks like this php require_once Project.inc function generate_navigation_project name try if name throw new Exception project new Project name catch Exception e return unknown project table tr td Author td td project- author tr tr td Summary td td project- short_description tr tr td Availability td td a href project- file_url click here a td tr tr td project- long_description td tr table php This looks almost exactly like your first attempt for caching the entire project page and in fact you can use the same caching strategy you applied there. The only change you Integrating Caching into Application Code 279 should make is to alter the get_cachefile function in order to avoid colliding with cache files from the full page php require_once 1Project.inc function generate_navigation_project name try if name throw new Exception cache new Cache_File Project get_cachefile_nav name if text cache- get print text return project new Project name cache- begin catch Exception e return unkonwn project1 table tr td Author td td project- author tr tr td Summary td td project- short_description tr tr td Availability td td a href project- file_url click here a td tr tr td project- long_description td tr table php cache- end And in Project.inc you add this public function get_cachefile_nav name global CACHEBASE return CACHEBASE projects nav name.cache 280 Chapter 10 Data Component Caching It s as simple as that Implementing a Query Cache Now you need to tackle the weather element of the navigation bar you ve been working with.You can use the Simple Object Application Protocol SOAP interface at xmeth-ods.net to retrieve real-time weather statistics by ZIP code. Don t worry if you have not seen SOAP .