CakePHP 支持 APC、XCache 等吗?
CakePHP 支持 APC、XCache 等吗?
Does CakePHP have support for APC, XCache and others?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
CakePHP 支持 APC、XCache 等吗?
Does CakePHP have support for APC, XCache and others?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
在cake的
/app/config/core.php
中,有一些选项供您设置缓存引擎(版本高于1.2)。例如In cake's
/app/config/core.php
,there are some options for you to set the cache engines(version newer than 1.2).e.g它应该支持 APC 作为操作码缓存——毕竟它只是 PHP 代码。
似乎有一个与 APC 相关的类使用 APC 作为数据缓存:请参阅
ApcEngine
。另请参阅手册中:7.2.2 中的缓存引擎Cake,其中表示支持 APC、XCache、File 和 memcached。
It should support APC as an opcode cache -- it's just PHP code, afterall.
And it seems there is an APC-related class to use APC as a cache for data : see
ApcEngine
.See also, in the manual : 7.2.2 Cache Engines in Cake, in which it says there is support for APC, XCache, File, and memcached.
只是为了添加已经提供的其他好的答案,有一些技巧可以让 cake 使用文件缓存以外的任何内容来进行内部缓存。这段代码将使cake使用APC,Xcache,无论它的核心缓存(本例中是APC)
Cake还可以通过将其放入控制器/应用程序控制器来缓存您的模型。
然而,模型只能使用文件缓存
这些都是从这篇文章中盗来的,其中包括一堆使用cake的缓存机制来加速你的应用程序的方法
http://www.pseudocoder.com/archives/8-ways-to-speed-up-cakephp-apps
另外正如 Pascal 所提到的,通过安装和配置 APC,您的 PHP 操作码会自动缓存。
为了获得更多的缓存优势,php 支持 memcache 作为文件会话存储的替代方案,这在负载平衡环境中特别有用。单个服务器实现的一个示例是将其放入您的 ini
并将其放入您的 core.php
Just to add to the other good answers provided already, there are some tricks to get cake to use anything other than file cache for it's internal caching. This code will make cake use APC,Xcache, whatever for it's core cache (APC in this example)
Cake can also cache your models by putting this in your controllers/appcontroller.
However, models can only use file cache
These were all stolen from this article, which includes a bunch of ways to use cake's caching mechanisms to speed up your app
http://www.pseudocoder.com/archives/8-ways-to-speed-up-cakephp-apps
Also, as Pascal has mentioned, by installing and configuring APC, your PHP opcode is automatically cached.
For even more caching goodness, php supports memcache as an alternative to files as a session store, which is particularly useful in load balanced environments. An example of a single server implementation would be to put this in your ini
And this in your core.php
在 CakePhp 2.0 中,Apc 会被自动检测和设置。在你的 core.php 中你可以找到:
}
In CakePhp 2.0 Apc is automatically detected and set. In your core.php you can find:
}
请注意,在 CakePHP 2.2 之后,自动 APC 检测被禁用。
在 2.2.1 中使用了 APC,如果检测到: https: //github.com/cakephp/cakephp/blob/2.2.1/app/Config/core.php
从 2.3 开始默认引擎是“File”。最新稳定
/app/Config/core.php
https://github.com/cakephp/cakephp/blob/2.4.4/app/Config/core.php#L352从 2.4.4 开始,支持这些
文档:
http://book.cakephp.org/2.0/en/core -libraries/caching.html#caching
FileCache 文件缓存是使用本地文件的简单缓存。它是最慢的缓存引擎,并且不提供尽可能多的原子操作功能。然而,由于磁盘存储通常非常便宜,因此在文件中存储大型对象或不经常写入的元素效果很好。这是 2.3+ 的默认缓存引擎
ApcCache APC 缓存使用 PHP APC 扩展。此扩展使用网络服务器上的共享内存来存储对象。这使得它非常快,并且能够提供原子读/写功能。默认情况下,2.0-2.2 中的 CakePHP 将使用此缓存引擎(如果可用)。
Wincache Wincache 使用Wincache 扩展。 Wincache 在功能和性能上与 APC 类似,但针对 Windows 和 IIS 进行了优化。
XcacheEngine Xcache 是一个 PHP 扩展,提供与 APC 类似的功能。
MemcacheEngine 使用 Memcache 扩展。 Memcache 提供了一个非常快速的缓存系统,可以分布在许多服务器上,并提供原子操作。
RedisEngine 使用 phpredis 扩展。 Redis 提供了类似于 memcached 的快速且持久的缓存系统,也提供原子操作。
如果您好奇使用哪一个。检查它们的开发状态。
Note that after CakePHP 2.2 ,auto APC detection is disabled.
In 2.2.1 APC was used, if detected: https://github.com/cakephp/cakephp/blob/2.2.1/app/Config/core.php
Since 2.3 default engine is "File". Latest stable
/app/Config/core.php
https://github.com/cakephp/cakephp/blob/2.4.4/app/Config/core.php#L352As of 2.4.4 these are supported
Documentation:
http://book.cakephp.org/2.0/en/core-libraries/caching.html#caching
FileCache File cache is a simple cache that uses local files. It is the slowest cache engine, and doesn’t provide as many features for atomic operations. However, since disk storage is often quite cheap, storing large objects, or elements that are infrequently written work well in files. This is the default Cache engine for 2.3+
ApcCache APC cache uses the PHP APC extension. This extension uses shared memory on the webserver to store objects. This makes it very fast, and able to provide atomic read/write features. By default CakePHP in 2.0-2.2 will use this cache engine if it’s available.
Wincache Wincache uses the Wincache extension. Wincache is similar to APC in features and performance, but optimized for Windows and IIS.
XcacheEngine Xcache is a PHP extension that provides similar features to APC.
MemcacheEngine Uses the Memcache extension. Memcache provides a very fast cache system that can be distributed across many servers, and provides atomic operations.
RedisEngine Uses the phpredis extension. Redis provides a fast and persistent cache system similar to memcached, also provides atomic operations.
If you are curious about using which one. Check the development state of them.