wloe2gf 发表于 2024-10-4 15:57:36

[精选] php缓存的类型有哪些?都是怎么用的?


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">以下请在本公众号里操作</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">回复「<span style="color: black;">微X</span>群」</span></strong></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">加入PHP技术交流群,<span style="color: black;">一块</span>学习交流</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">回复「商务合作」</span></strong></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">就可</span>获取合作方式与客服联系方式。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">一个网站<span style="color: black;">或</span>一个应用的标准流程是浏览器向应用服务器发出请求,应用服务器做<span style="color: black;">有些</span>计算和<span style="color: black;">规律</span>判断之后再请求数据库,数据库收到请求后在经过计算将数据返回给应用服务器,应用服务器再次计算后把数据返回给浏览器。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">那样</span>,随着web业务的<span style="color: black;">繁杂</span>度和并发量的<span style="color: black;">增多</span>,应用服务器所做的计算和<span style="color: black;">规律</span>处理越来越多,而应用服务器的资源是有限的,且数据库每秒接受并处理请求的次数<span style="color: black;">亦</span>是有限的。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">为了在有限的资源<span style="color: black;">供给</span>尽可能多的吞吐量,<span style="color: black;">便是</span>减少计算量,缩短请求流程(减少网络I/O或硬盘I/O)。</span><span style="color: black;"><span style="color: black;">此时</span>,就用到了缓存(Cache)</span></p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;"><strong style="color: blue;"><span style="color: black;">php缓存类型</span></strong></h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">1、数据缓存:</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">这儿</span>所说的数据缓存<span style="color: black;">指的是</span>数据库<span style="color: black;">查找</span>PHP缓存机制,每次<span style="color: black;">拜访</span>页面的时候,都会先检测相应的缓存数据<span style="color: black;">是不是</span>存在,<span style="color: black;">倘若</span>不存在,就连接数据库,得到数据,并把<span style="color: black;">查找</span>结果序列化后<span style="color: black;">保留</span>到文件中,以后<span style="color: black;">一样</span>的<span style="color: black;">查找</span>结果就直接从缓存表或文件中<span style="color: black;">得到</span><span style="color: black;">。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">用的最广的例子看Discuz的搜索功能,把结果ID缓存到一个表中,下次搜索相同关键字时先搜索缓存表。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">举个常用的<span style="color: black;">办法</span>,多表<span style="color: black;">相关</span>的时候,把附表中的内容生成数组<span style="color: black;">保留</span>到主表的一个字段中,需要的时候数组分解一下,<span style="color: black;">这般</span>的好处是只读一个表,坏处<span style="color: black;">便是</span>两个数据同步会多不少<span style="color: black;">过程</span>,数据库永远是瓶颈,用硬盘换速度,是这个的关键点。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">2、页面缓存:</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">每次<span style="color: black;">拜访</span>页面的时候,都会先检测相应的缓存页面文件<span style="color: black;">是不是</span>存在,<span style="color: black;">倘若</span>不存在,就连接数据库,得到数据,<span style="color: black;">表示</span>页面并<span style="color: black;">同期</span>生成缓存页面文件,<span style="color: black;">这般</span>下次<span style="color: black;">拜访</span>的时候页面文件就发挥<span style="color: black;">功效</span>了。(模板引擎和网上<span style="color: black;">平常</span>的<span style="color: black;">有些</span>PHP缓存机制类<span style="color: black;">一般</span>有此功能)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">3、时间触发缓存:</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">检测</span>文件<span style="color: black;">是不是</span>存在并且时间戳<span style="color: black;">少于</span>设置的过期时间,<span style="color: black;">倘若</span>文件修改的时间戳比当前时间戳减去过期时间戳大,<span style="color: black;">那样</span>就用缓存,否则更新缓存。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">4、内容触发缓存:</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当<span style="color: black;">插进</span>数据或更新数据时,强制更新PHP缓存机制。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">5、静态缓存:</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">这儿</span>所说的静态缓存<span style="color: black;">指的是</span>静态化,直接生成HTML或XML等文本文件,有更新的时候重生成一次,适合于不太变化的页面,这就不说了。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">实例扩展:</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">Memcached;</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。它<span style="color: black;">经过</span>在内存中缓存数据和对象来减少读取数据库的次数,从而<span style="color: black;">加强</span>动态、数据库驱动网站的速度。Memcached基于一个存储键/值对的hashmap。</p><span style="color: black;">//&nbsp;初始化</span>$cache&nbsp;=&nbsp;<span style="color: black;">new</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;Memcache();</p>$cache-&gt;pconnect(<span style="color: black;">127.0</span><span style="color: black;">.0</span><span style="color: black;">.1</span>,&nbsp;<span style="color: black;">11211</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">);</p><span style="color: black;">//&nbsp;写入</span>$cache-&gt;set(CACHE_PREFIX&nbsp;.&nbsp;$key,&nbsp;$value,&nbsp;MEMCACHE_COMPRESSED,&nbsp;$expire);(CACHE_PREFIX&nbsp;为了避免命名冲突,最好加一个前缀,MEMCACHE_COMPRESSED一个标记,设置为<span style="color: black;">0</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">暗示</span>不压缩)</p><span style="color: black;">//&nbsp;读取</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$cache-&gt;get(CACHE_PREFIX&nbsp;.&nbsp;$key);</p><span style="color: black;">//&nbsp;删除</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$cache-&gt;delete(CACHE_PREFIX&nbsp;.&nbsp;$key);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">R</span><span style="color: black;">edis:</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">是</span><span style="color: black;">一个开源的<span style="color: black;">运用</span>ANSI C语言编写、支持网络、可基于内存<span style="color: black;">也</span>可持久化的日志型、</span>Key-Value<span style="color: black;">数据库,并<span style="color: black;">供给</span>多种语言的API。</span><span style="color: black;">类似的安装好php扩展// 初始化</span>$cache = new Redis();</p><span style="color: black;">//&nbsp;初始化$cache&nbsp;=&nbsp;new&nbsp;\Redis();</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$cache-&gt;connect(CACHE_HOSTNAME,&nbsp;CACHE_PORT);</p><span style="color: black;">//&nbsp;先<span style="color: black;">检测</span><span style="color: black;">是不是</span>存在,<span style="color: black;">而后</span>写入并设置有效时间</span><span style="color: black;">if</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">($cache-&gt;exists($key)){</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;$cache-&gt;delete(CACHE_PREFIX&nbsp;.&nbsp;$key);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$cache-&gt;set(CACHE_PREFIX&nbsp;.&nbsp;$key,&nbsp;serialize($value));</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$cache-&gt;expire(CACHE_PREFIX&nbsp;.&nbsp;$key,&nbsp;$expire);</p><span style="color: black;">//&nbsp;读取</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$cache-&gt;get(CACHE_PREFIX&nbsp;.&nbsp;$key);</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">除了上面的<span style="color: black;">有些</span>缓存类型,<span style="color: black;">这儿</span><span style="color: black;">亦</span>给<span style="color: black;">大众</span>讲讲<strong style="color: blue;"><span style="color: black;">php加速缓存器opcache,apc,xcache,eAccelerator原理与配置<span style="color: black;">办法</span>。</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">1、</span>opcache</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">opcache <span style="color: black;">经过</span>将 PHP 脚本预编译的字节码存储到共享内存中来<span style="color: black;">提高</span> PHP 的性能, 存储预编译字节码的好处<span style="color: black;">便是</span> 省去了每次加载和解析 PHP 脚本的开销。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">PHP 5.5.0 及后续版本中<span style="color: black;">已然</span>绑定了 opcache 扩展。<span style="color: black;">针对</span> PHP 5.2,5.3 和 5.4 版本<span style="color: black;">能够</span><span style="color: black;">运用</span>PECL扩展中的 opcache 库。</p>

    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">windows下的php扩展下载<span style="color: black;">位置</span>:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">http://windows.php.net/downloads/pecl/releases/</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">打开php.ini文件,找到</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;dll<span style="color: black;">位置</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">extension=php_opcache.dll</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;开关打开</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">opcache.enable=1</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;开启CLI</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">opcache.enable_cli=1</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;可用内存, 酌情而定, 单位为:Mb</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">opcache.memory_consumption=128</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;Zend&nbsp;Optimizer&nbsp;+&nbsp;暂存池中字符串的占内存总量.(单位:MB)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">opcache.interned_strings_buffer=8</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;对多缓存文件限制,&nbsp;命中率不到&nbsp;100%&nbsp;的话,&nbsp;<span style="color: black;">能够</span>试着<span style="color: black;">加强</span>这个值</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">opcache.max_accelerated_files=10000</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;opcache&nbsp;会在一<span style="color: black;">按时</span>间内去<span style="color: black;">检测</span>文件的修改时间,&nbsp;<span style="color: black;">这儿</span>设置<span style="color: black;">检测</span>的时间周期,&nbsp;默认为&nbsp;2,&nbsp;(单位:秒)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">opcache.revalidate_freq=1</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;打开快速关闭,&nbsp;打开这个在PHP&nbsp;Request&nbsp;Shutdown的时候回收内存的速度会<span style="color: black;">加强</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">opcache.fast_shutdown=1</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2、</span>APC</strong>
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Alternative PHP Cache (APC) 是一个开放自由的PHP opcode 缓存。它的<span style="color: black;">目的</span>是<span style="color: black;">供给</span>一个自由、 开放,和健全的框架用于缓存和优化PHP的中间代码。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下载apc扩展dll,<span style="color: black;">选取</span>你对应的PHP版本</p>http://windows.php.net/downloads/pecl/releases/apc/
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">把下载的php_apc.dll放入php的ext扩展目录下。</p>打开php.ini文件,配置如下:[<span style="color: black;">apc</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">]</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">extension=php_apc.dll</p>apc.enabled=<span style="color: black;">1</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;共享内存块的数目</p>apc.shm_segments=<span style="color: black;">1</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;共享内存块的<span style="color: black;">体积</span>(单位:MB)</p>apc.shm_size=<span style="color: black;">64</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;优化级别,更高的值则<span style="color: black;">运用</span>更主动的优化</p>apc.optimization=<span style="color: black;">1</span>;&nbsp;源文件的数目,不确定设置为<span style="color: black;">0</span>apc.num_files_hint=<span style="color: black;">0</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;缓存条目在缓冲区中<span style="color: black;">准许</span>逗留的秒数</p>apc.ttl=<span style="color: black;">7200</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;针对<span style="color: black;">每一个</span>用户缓存条目在缓冲区中<span style="color: black;">准许</span>逗留的秒数</p>apc.user_ttl=<span style="color: black;">7200</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;缓存条目在垃圾回收表中能够存在的秒数</p>apc.gc_ttl=<span style="color: black;">7200</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;文件写锁</p>apc.write_lock=<span style="color: black;">on</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">3、</span>xcache</strong>
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">xcache是一个开源的 opcode 缓存器/优化器。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下载xcache,<span style="color: black;">选取</span>对应PHP版本的xcache</p>http://xcache.lighttpd.net/pub/Releases/
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">把php_xcache.dll放到php的ext目录下。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">打开php.ini,配置如下:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">extension&nbsp;=&nbsp;php_xcache.dll</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"></p>xcache.admin.enable_auth&nbsp;=<span style="color: black;">On</span>xcache.admin.user&nbsp;=&nbsp;<span style="color: black;">"admin"</span>xcache.admin.pass&nbsp;=&nbsp;<span style="color: black;">"md5后你的<span style="color: black;">秘码</span>"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;<span style="color: black;">选取</span>底层内存共享实现<span style="color: black;">方法</span></p>xcache.shm_scheme&nbsp;=&nbsp;<span style="color: black;">"mmap"</span>xcache.size&nbsp;=&nbsp;<span style="color: black;">128</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">M</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;设置为CPU数</p>xcache.count&nbsp;=<span style="color: black;">1</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;只是个参考值</p>xcache.slots&nbsp;=&nbsp;<span style="color: black;">8</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">K</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;缓存时间</p>xcache.ttl&nbsp;=&nbsp;<span style="color: black;">1200</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;垃圾回收的时间间隔</p>xcache.gc_interval&nbsp;=&nbsp;<span style="color: black;">1200</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;同上,针对变量缓存设置</p>xcache.var_size&nbsp;=&nbsp;<span style="color: black;">4</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">M</p>xcache.var_count&nbsp;=&nbsp;<span style="color: black;">1</span>xcache.var_slots&nbsp;=<span style="color: black;">8</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">K</p>xcache.var_ttl&nbsp;=&nbsp;<span style="color: black;">1200</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;变量最大缓存时间</p>xcache.var_maxttl&nbsp;=&nbsp;<span style="color: black;">7200</span>xcache.var_gc_interval&nbsp;=&nbsp;<span style="color: black;">1200</span>xcache.var_namespace_mode&nbsp;=&nbsp;<span style="color: black;">0</span>xcache.var_namespace&nbsp;=&nbsp;<span style="color: black;">""</span>xcache.readonly_protection&nbsp;=<span style="color: black;">Off</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">;&nbsp;<span style="color: black;">针对</span>win系统,<span style="color: black;">这儿</span>不是文件路径</p>xcache.mmap_path&nbsp;=&nbsp;<span style="color: black;">"xcache"</span>xcache.coredump_directory&nbsp;=&nbsp;<span style="color: black;">""</span>xcache.coredump_type&nbsp;=&nbsp;<span style="color: black;">0</span>xcache.disable_on_crash&nbsp;=&nbsp;<span style="color: black;">Off</span>xcache.experimental&nbsp;=&nbsp;<span style="color: black;">Off</span>xcache.cacher&nbsp;=&nbsp;<span style="color: black;">On</span>xcache.stat&nbsp;=&nbsp;<span style="color: black;">On</span>xcache.optimizer&nbsp;=&nbsp;<span style="color: black;">Off</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"></p>xcache.coverager&nbsp;=&nbsp;<span style="color: black;">Off</span>xcache.coverager_autostart&nbsp;=&nbsp;<span style="color: black;">On</span>xcache.coveragedump_directory&nbsp;=<span style="color: black;">""</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">4、</span>eAccelerator</strong>
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">eAccelerator是一个自由开放源码php加速器,优化和动态内容缓存,<span style="color: black;">加强</span>了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除。它还有对脚本起优化<span style="color: black;">功效</span>,以加快其执行效率。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下载eAccelerator</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">http://www.sitebuddy.com/PHP/Accelerators/eAccelerator_windows_binaries_builds</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">把下载到的eAccelerator_ts.dll放到php的ext目录下。</p>打开php.ini,配置如下:
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"></p>extension=<span style="color: black;">"eAccelerator_ts.dll"</span>eaccelerator.shm_size=<span style="color: black;">"16"</span>eaccelerator.cache_dir=<span style="color: black;">"设置缓存目录"</span>eaccelerator.enable=<span style="color: black;">"1"</span>eaccelerator.optimizer=<span style="color: black;">"1"</span>eaccelerator.check_mtime=<span style="color: black;">"1"</span>eaccelerator.debug=<span style="color: black;">"0"</span>eaccelerator.log_file&nbsp;=&nbsp;<span style="color: black;">"设置日志文件"</span>eaccelerator.filter=<span style="color: black;">""</span>eaccelerator.shm_max=<span style="color: black;">"0"</span>eaccelerator.shm_ttl=<span style="color: black;">"0"</span>eaccelerator.shm_prune_period=<span style="color: black;">"0"</span>eaccelerator.shm_only=<span style="color: black;">"0"</span>eaccelerator.compress=<span style="color: black;">"1"</span>eaccelerator.compress_level=<span style="color: black;">"9"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"></p>extension=<span style="color: black;">"eAccelerator_ts.dll"</span>eaccelerator.shm_size=<span style="color: black;">"16"</span>eaccelerator.cache_dir=<span style="color: black;">"设置缓存目录"</span>eaccelerator.enable=<span style="color: black;">"1"</span>eaccelerator.optimizer=<span style="color: black;">"1"</span>eaccelerator.check_mtime=<span style="color: black;">"1"</span>eaccelerator.debug=<span style="color: black;">"0"</span>eaccelerator.log_file&nbsp;=&nbsp;<span style="color: black;">"设置日志文件"</span>eaccelerator.filter=<span style="color: black;">""</span>eaccelerator.shm_max=<span style="color: black;">"0"</span>eaccelerator.shm_ttl=<span style="color: black;">"0"</span>eaccelerator.shm_prune_period=<span style="color: black;">"0"</span>eaccelerator.shm_only=<span style="color: black;">"0"</span>eaccelerator.compress=<span style="color: black;">"1"</span>eaccelerator.compress_level=<span style="color: black;">"9"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">原文链接:https://www.jb51.net/article/233389.htm</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">点个赞</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/Ljib4So7yuWge7Mibiad1tV0iaF8zSD5gzicbYiaOtl6tmz4onkADe25mdeWcVhZlQ8Q0bH73nZAwICyJ4pPgJU3VrCg/640?wx_fmt=gif&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">再走吧</span></strong></p>




m5k1umn 发表于 2024-10-23 21:34:47

可以发布外链的网站 http://www.fok120.com/

b1gc8v 发表于 2024-10-25 21:40:42

你的见解真是独到,让我受益良多。

7wu1wm0 发表于 2024-11-11 07:52:32

回顾历史,我们不难发现:无数先辈用鲜血和生命铺就了中华民族复兴的康庄大道。
页: [1]
查看完整版本: [精选] php缓存的类型有哪些?都是怎么用的?