How to use cache in CakePHP?

I want to use cache in CakePHP . How to use it?

+6
php caching cakephp
source share
6 answers
if(!($cachedPosts = Cache::read('cached_posts'))) { $cachedPosts = $this->Post->find('all'); Cache::write('cached_posts', $cachedPosts); } 

In this code example, you will see if you have cached data - if not, extract it from the database and write it in the cache. At the next request, the data will come from the cache, not from the database.

+6
source share

In the manual cache documentation (1.2): http://book.cakephp.org/view/213/Cache

I would recommend disabling caching during development; you will find (hopefully not as difficult as me) that your models and views do not change as expected.

+3
source share

Before using the cache, we must check that the cache is enabled or disabled in

application /Config/core.php.

we must uncomment this line in the core.php file

 //Configure::write('Cache.disable', true); 

After that we use

 $varible = Cache::read('variable'); Cache::write('posts', $posts); Cache::delete(); 
+2
source share

Check the file / app / config / core.php.

0
source share

CakePHP also provides default file-based caching at the model level ...

and then save manual caching for any application that you can use

 Cache::set(array('duration' => '+100 days')); Cache::write(file_path); 

type functions to support file-based cache

For memcache or any other concept, you can use the following links as a reference:

0
source share

All Articles