Does CakePHP support APC, XCache and others?

Does CakePHP support APC, XCache and others?

+4
source share
5 answers

The /app/config/core.php cake has several options for setting caching mechanisms (version higher than 1.2) .eg

  APC (http://pecl.php.net/package/APC) Cache::config('default', array( 'engine' => 'Apc', //[required] 'duration'=> 3600, //[optional] 'probability'=> 100, //[optional] 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string )); 
+6
source

It should support APC as an operation cache code - it's just PHP code, after.

And it looks like APC uses a class related to APC as a cache: see ApcEngine .
See also the manual: 7.2.2. Cache Engines in Cake , which says that there is support for APC, XCache, File and memcached.

+4
source

Just to add the other good answers already provided, there are some tricks to get the cake, to use anything other than the file cache to cache it internally. This code will make use of the APC cake, Xcache, regardless of its main cache (APC in this example)

 Cache::config('_cake_core_', array( 'engine' => 'Apc', 'duration'=> 3600, 'probability'=> 100, ) ); 

Cake can also cache your models by putting them in their controllers / applications.

 var $persistModel = true; 

However, models can use the file cache.

All of them were stolen from this article, which includes many ways to use cache-caching mechanisms to speed up your application.

http://www.pseudocoder.com/archives/8-ways-to-speed-up-cakephp-apps

In addition, as Pascal noted, by installing and configuring APC, your PHP operation code is automatically cached.

For even greater caching convenience, php supports memcache as an alternative to files as a session repository, which is especially useful in a load-balanced environment. An example of a single server implementation would be to put this in your ini

 extension=memcache.so session.save_handler = memcache session.save_path = "tcp://127.0.0.1:11211?persistent=1" 

And this is in your core.php

 Configure::write('Session.save', 'php'); 
+1
source

In CakePhp 2.0, Apc is automatically detected and installed. In your core.php you can find:

 $engine = 'File'; if (extension_loaded('apc') && function_exists('apc_dec') && (php_sapi_name() !== 'cli' || ini_get('apc.enable_cli'))) { $engine = 'Apc'; 

}

+1
source

Please note that after CakePHP 2.2, automatic APC discovery 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 by default - "File". Last stable /app/Config/core.php https://github.com/cakephp/cakephp/blob/2.4.4/app/Config/core.php#L352


Starting from version 2.4.4 supported

  • File engine
  • APC
  • Wincache
  • XCache
  • Memcache
  • Redis

Documentation: http://book.cakephp.org/2.0/en/core-libraries/caching.html#caching

  • FileCache A file cache is a simple cache that uses local files. This is the slowest caching mechanism and does not provide as many functions for atomic operations. However, since disk storage is often quite cheap, storing large objects or items that are rarely written works well in files. This is the default cache mechanism for 2.3+

  • ApcCache APC cache uses the APC PHP extension. This extension uses shared memory on a web server to store objects. This makes it very fast and able to provide atomic read / write functions. By default, CakePHP in 2.0-2.2 will use this caching mechanism, if available.

  • Wincache Wincache uses the Wincache extension. Wincache is similar to APC in features and performance, but is optimized for Windows and IIS.

  • XcacheEngine Xcache is a PHP extension that provides similar APC features.

  • 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 consistent caching system similar to memcached and also provides atomic operations.


If you are wondering which one. Check the status of their development.

0
source

Source: https://habr.com/ru/post/1306507/


All Articles