PHP缓存详谈
咱们会问啥是缓存!精干啥!本来缓存相当于内存。保留一段时间!
<?php } include(./adodb/adodb.inc.php); $ADODB_CACHE_DIR='tmp'; $db=NewADOConnect('mysql'); $db->connect('localhost','root','123456','mysql'); $sql="select * from user"; $db->cacheexecute(300,$sql); ?> |
这样在TMP目录下生成了缓存!(缓存文件是序列化的数据。) 当下次在履行的时分,咱们直接从缓存里边读取数据。SMARTY缓存:
< ?php require('./smarty/Smarty.class.php'); $smarty = new Smarty; Z) $smarty->caching = true; if(!$smarty->is_cached('index.tpl')) // No cache available, do variable assignments here. ) $contents = get_database_contents(); $smarty->assign($contents); } $smarty->display('index.tpl'); ) ?> |
这个首要判别是不是有这个缓存文件!没有直接连接数据库!有的话!履行DISPLAY。即是读取缓存。咱们看到上面的2个比如!对缓存有很大的理解了吧!
推荐文章
2025-01-18
2024-11-28
2024-11-09
2024-10-25
2024-06-25
2024-01-04
2023-11-06
2023-10-30
2023-10-13
2023-10-10
稳定
产品高可用性高并发贴心
项目群及时沟通专业
产品经理1v1支持快速
MVP模式小步快跑承诺
我们选择声誉坚持
10年专注高端品质开发