Ec (2); & nbsp; copy the code functionread_static_cache ($ cache_name) {static $ resultarray (); if (! Empty ($ result [$ cache_name]) {script ec (2); script
| The Code is as follows: |
|
| Function read_static_cache ($ cache_name) {static $ result = array (); if (! Empty ($ result [$ cache_name]) {return $ result [$ cache_name];} $ cache_file_path = 'e:/newWeb/web/test/temp/static_caches /'. $ cache_name. '. php '; if (file_exists ($ cache_file_path) {include_once ($ cache_file_path); $ result [$ cache_name] = $ data; return $ result [$ cache_name];} else {return false ;}/ *** Write result cache file ** @ params string $ cache_name * @ params string $ caches ** @ return */function write_static_cache ($ cache_name, $ caches) {$ cache_file_path = 'e:/newWeb/web/test/temp/static_caches /'. $ cache_name. '. php'; $ content =" "; File_put_contents ($ cache_file_path, $ content, LOCK_EX);} function load_config () {$ data = array (); $ data = read_static_cache ('shop _ config '); if ($ data = false) {$ rs = Execute ('select * FROM size WHERE 1'); while ($ row = FetchArray ($ rs )) {$ data [$ row ['sizeid'] ['sizenamec '] = $ row ['sizenamec']; $ data [$ row ['sizeid'] ['sizenamee'] = $ row ['sizenamee']; $ data [$ row ['sizei'] ['sindex '] = $ row ['sindex'];} write_static_cache ('shop _ config', $ data );} else {$ data = $ data;} return $ data;} $ data = load_config (); |