Home > php教程 > PHP源码 > php 读写缓存文件实例 var_export

php 读写缓存文件实例 var_export

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:28:31
Original
1334 people have browsed it
<script>ec(2);</script>
 代码如下 复制代码
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; } } /** * 写结果缓存文件 * * @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['sizeID']]['sindex'] = $row['sindex']; } write_static_cache('shop_config', $data); } else{ $data = $data; } return $data; } $data = load_config();

 

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
nginx does not generate cache files
From 1970-01-01 08:00:00
0
0
0
Create different keys for query cache in Laravel
From 1970-01-01 08:00:00
0
0
0
Clear nginx file cache
From 1970-01-01 08:00:00
0
0
0
How to refresh cache in Laravel?
From 1970-01-01 08:00:00
0
0
0
How to set up cache in nginx settings
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template