php+memcached实现定时静态页面生成
来源:互联网 发布:手机网络共享怎么设置 编辑:程序博客网 时间:2024/06/15 18:07
<?phpheader('content-type:text/html;charset="utf8"');error_reporting(E_ALL^E_NOTICE^E_WARNING);$memcache = new Memcache();$memcache->connect('localhost','11211')or die('Memcached连接失败');//定义一个对象$tmp_object = new stdClass();$tmp_object->username='tomm';$tmp_object->password='123';$tmp_object->msg='hello~my name is tom';//memcache->set('设置值的key','设置存储的值','是否使用MEMCACHE_COMPRESSED压缩,0或false表示不压缩','过期时间/秒')$memcache->set('user',$tmp_object,false,10);$get_res = $memcache->get('user');// $id = $_GET['id'];$id = 11;$filename = "static_id_".$id.".html"; $status = filemtime($filename)+30>time();//判断文件创建及修改时间距当前时间是否超过30秒 if(file_exists($filename)&&$status){ $str = file_get_contents($filename);echo $str; }else{/***缓存开始***/ob_start();//下面的内容将存到缓存区中,显示的内容都将存到缓存区foreach ($get_res as $key => $value) {echo $key.'==>'.$value.'<br/>';}$content = ob_get_contents();//从缓存中获取内容ob_end_clean();//关闭缓存并清空/***缓存结束***/file_put_contents($filename, $content);echo $content; }?>
0 0
- php+memcached实现定时静态页面生成
- php技术生成静态页面的实现
- PHP生成静态页面
- PHP生成静态页面
- php 生成静态页面
- php 生成静态页面
- PHP生成静态页面
- PHP生成静态页面
- PHP生成静态页面
- PHP生成静态页面
- PHP生成静态页面
- php 生成静态页面
- PHP静态页面生成
- PHP生成静态页面
- PHP 静态页面生成
- php生成静态页面
- php生成静态页面
- PHP定时自动生成静态HTML的实现代码
- 第四次上机实验
- SQLSERVER聚合函数
- Python 绘制函数图形
- C语言综合实践-----C程序操作
- Run loop简析
- php+memcached实现定时静态页面生成
- hdu-5880 AC自动机 + 差分优化
- No.7 week9 optimal division
- 阅读effective stl 有感(一)
- thinkphp实现上传图文消息中的图片的接口
- 四区例
- JSP三大指令
- 第二章 Spring MVC入门
- ubuntu中使用nginx把本地80端口转到其他端口