教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php 读写缓存文件实例 var_export

php 读写缓存文件实例 var_export

发布时间:2016-10-28   编辑:jiaochengji.com
教程集为您提供php 读写缓存文件实例 var,export等资源,欢迎您收藏本站,我们将为您提供最新的php 读写缓存文件实例 var,export资源
<table style="background: #fb7" border="0" cellspacing="1" cellpadding="1" width="620" align="center"> <tbody> <tr> <td bgcolor="#ffe7ce" height="27" width="464"> 代码如下</td> <td style="cursor: pointer" bgcolor="#ffe7ce" width="109" align="center" onclick="doCopy('copy1783')">复制代码</td> </tr> <tr> <td style="padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px" id="copy1783" class="copyclass" bgcolor="#ffffff" valign="top" colspan="2">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();</td> </tr> </tbody> </table>

 

您可能感兴趣的文章:
php 读写缓存文件实例 var_export
php var_export读写实例类
PHP模板引擎Smarty缓存使用
php file读取到数组中有空格的解决方法
php页面缓存的例子(减经cpu与mysql负担)
var_export 与 var_dump用法介绍
超级精练的php缓存类与实例
php 缓存技术实例
var_export与var_dump的不同
emlog中使用memcache缓存配置修改方法

[关闭]
~ ~