php缓存机制
2024-08-24 07:44:10
1.全页面静态化缓存
<?php
ob_start();//如果php.ini已经开启,那么这里会开启一个新的输出缓冲区;
echo "<!DOCTYPE html>
<html>
<head>
<title>文档的标题</title>
</head>
<body>
文档的内容......
</body>
</html>";
//获取缓冲区中的页面,并清除缓冲区
$content = ob_get_clean();
//将页面保存成为静态文件
file_put_contents("abc.htm",$content);
?>
2.内存式缓存
<?php
$memcachehost = '192.168.6.191';
$memcacheport = 11211;
$memcachelife = 60;
$memcache = new Memcache;
$memcache->connect($memcachehost,$memcacheport) or die ("Could not connect");
$memcache->set('key','缓存的内容');
$get = $memcache->get($key); //获取信息
?>
最新文章
- .NET CoreCLR开发人员指南(上)
- 简单的浏览器调试——console命令
- 学习maple
- missing locales
- SSRS匿名访问
- 最大权闭合图(Road constructions)hdu3917
- [改善Java代码]不推荐覆写start方法
- 基于jQuery的图片左右轮播,基本原理通用
- 编程的宗派(OOP与FP孰优孰劣)--王垠
- JQuery 模糊匹配
- Java this 关键字的用法
- SpringBoot中MongoDB注解概念及使用
- ARP欺骗配置及演示过程
- complex类的设计实现
- Extjs4.2 TreeView TreeStore 移除节点不触发delete(remove node don&#39;t trigger delete method)
- JavaScript 浮点数陷阱及解法
- ubuntu 16.04安装ibus中文输入法
- linux shell 正则表达式(BREs,EREs,PREs)的比较
- P2046 [NOI2010]海拔 平面图转对偶图(最小割-》最短路)
- fs.createReadStream(filepath).pipe(response);这句是什么意思?
热门文章
- 51nod 1832 先序遍历与后序遍历(dfs+高精度)
- 1月4日笔记 (vi编辑器)更新...
- HTML元素 绑定href属性
- (一)PHP简介
- ztree异步加载树节点
- VC.【转】采用_beginthread/_beginthreadex函数创建多线程
- [原][粒子特效][spark]发射器emitter
- cmd中mvn命令,出现No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
- vue中 父子组件的通讯
- Python中数据类型