CakePHP: APC caching still creates cache files, lack of performance

My problem:

I am doing an Apache Benchmark test to check if CakePHP APC engine is working. However, if I configure Cake caching configuration to use the APC mechanism, cache files with serialized cached data are still created in the tmp folder, which makes me think that file caching is being used.

I also do not get any performance benefit: using APC and file engines, test results are ~ 4 sec. If I hard-coded simple apc_add () and apc_fetch functions in my controller, the test result improved: ~ 3.5 s.

SO APC works, but Cake cannot use it.

My setup:

bootstrap.php:

/*Cache::config('default', array( 'engine' => 'File', 'duration'=> '+999 days', 'prefix' => 'file_', ));*/ Cache::config('default', array( 'engine' => 'Apc', 'duration'=> '+999 days', 'prefix' => 'apc_', )); 

controller:

 $catalogsLatest = Cache::read('catalogsLatest'); if(!$catalogsLatest){ $catalogsLatest = $this->Catalog->getCatalogs('latest', 5, array('Upload')); Cache::write('catalogsLatest', $catalogsLatest); } 

php.ini:

 [APC] apc.enabled = 1 apc.enable_cli = 1 apc.max_file_size = 64M 

If I check Cache :: settings () in the controller before or after the cache is executed, I get the following results:

 Array ( [engine] => Apc [path] => E:\wamp\www\cat\app\tmp\cache\ [prefix] => apc_ [lock] => 1 [serialize] => [isWindows] => 1 [mask] => 436 [duration] => 86313600 [probability] => 100 [groups] => Array ( ) ) 

I am using CakePHP 2.2.4.

+4
source share
1 answer

Yes, of course, APC cache will improve the performance of your cakephp based application . So, let's check your settings from my next instructions and let me know after after the test run a test and tell me the result, you can cache your entire HTML view file in the cache using the APC cache mechanism in CakePHP. Cake CacheHelper will do the job for you. Suppose you have a PostsController , and you want to cache all the files of your kind associated with this controller. In this case, first of all, you must define the following code in your controller.

  class PostsController extends AppController { public $helpers = array('Cache'); } 

And in your bootstrap.php file you need to add CacheDispatcher .

  Configure::write('Dispatcher.filters', array( 'CacheDispatcher' ) ); 

And now, again in your PostsController , you should talk about cache files.

  public $cacheAction = array( 'view' => 36000, 'index' => 48000 ); 

This will close the action for 10 hours, and the index for 13 hours.

Tell me your apache instrumental test result. I think that basically a similar issue is being discussed in another thread fooobar.com/questions/1470055 / ....

Thanks.

0
source

All Articles