Class CacheHelper
CacheHelper helps create full page view caching.
When using CacheHelper you don't call any of its methods, they are all automatically called by View, and use the $cacheAction settings set in the controller.
- AppHelper
- CacheHelper
Link: http://book.cakephp.org/2.0/en/core-libraries/helpers/cache.html
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/View/Helper/CacheHelper.php
Properties summary
-
$_counter
protectedinteger
Counter used for counting nocache section tags. -
$_match
protectedarray
Array of string that are replace with there var replace above. The strings are any content inside
<!--nocache--><!--/nocache-->
and includes the tags in views -
$_replace
protectedarray
Array of strings replaced in cached views. The strings are found between
<!--nocache--><!--/nocache-->
in views
Method Summary
-
_enabled() protected
Is CacheHelper enabled? should files + output be parsed. -
_parseContent() protected
Parse a file + output. Matches nocache tags between the current output and the current file stores a reference of the file, so the generated can be swapped back with the file contents when writing the cache file.
-
_parseFile() protected
Parse file searching for no cache tags -
_parseOutput() protected
Parse the output and replace cache tags -
_replaceSection() protected
Munges the output from a view with cache tags, and numbers the sections. This helps solve issues with empty/duplicate content.
-
_stripTags() protected
Strip cake:nocache tags from a string. Since View::render() only removes un-numbered nocache tags, remove all the numbered ones. This is the complement to _replaceSection.
-
_writeFile() protected
Write a cached version of the file -
afterLayout() public
Parses the layout file and stores content for cache file building. -
afterRenderFile() public
Parses the view file and stores content for cache file building. -
cache() public
Main method used to cache a view
Method Detail
_enabled() protected ¶
_enabled( )
Is CacheHelper enabled? should files + output be parsed.
Returns
_parseContent() protected ¶
_parseContent( string $file , string $out )
Parse a file + output. Matches nocache tags between the current output and the current file stores a reference of the file, so the generated can be swapped back with the file contents when writing the cache file.
Parameters
- string $file
- The filename to process.
- string $out
- The output for the file.
Returns
Updated content.
_parseFile() protected ¶
_parseFile( string $file , string $cache )
Parse file searching for no cache tags
Parameters
- string $file
- The filename that needs to be parsed.
- string $cache
- The cached content
_parseOutput() protected ¶
_parseOutput( string $cache )
Parse the output and replace cache tags
Parameters
- string $cache
- Output to replace content in.
Returns
with all replacements made to
_replaceSection() protected ¶
_replaceSection( )
Munges the output from a view with cache tags, and numbers the sections. This helps solve issues with empty/duplicate content.
Returns
The content with cake:nocache tags replaced.
_stripTags() protected ¶
_stripTags( string $content )
Strip cake:nocache tags from a string. Since View::render() only removes un-numbered nocache tags, remove all the numbered ones. This is the complement to _replaceSection.
Parameters
- string $content
- String to remove tags from.
Returns
String with tags removed.
_writeFile() protected ¶
_writeFile( string $content , string $timestamp , boolean $useCallbacks = false )
Write a cached version of the file
Parameters
- string $content
- view content to write to a cache file.
- string $timestamp
- Duration to set for cache file.
- boolean $useCallbacks optional false
Returns
success of caching view.
afterLayout() public ¶
afterLayout( string $layoutFile )
Parses the layout file and stores content for cache file building.
Parameters
- string $layoutFile
afterRenderFile() public ¶
afterRenderFile( string $viewFile , string $output )
Parses the view file and stores content for cache file building.
Parameters
- string $viewFile
- string $output
- The output for the file.
Returns
Updated content.