Class Cache
This class is used to manage cache in Hawk. It allows to save cache files in the folder /cache,
and detect if a file is cached. This class is very useful to increase the application performances.
-
Hawk\Singleton
-
Hawk\Cache
Methods summary
public
string
|
#
getCacheFilePath( string $cacheFile )
Get the full path for a given cache file path, relative to CACHE_DIR
Get the full path for a given cache file path, relative to CACHE_DIR
Parameters
- $cacheFile
- The path of the cache file
Returns
string The full path of the cache file
|
public
boolean
|
#
isCached( string $source, string $cacheFile )
Check if a file is cached. This function returns true if $cacheFile does not exist or if $source is newer than $cacheFile
Check if a file is cached. This function returns true if $cacheFile does not exist or if $source is newer than $cacheFile
Parameters
- $source
- The path of the source file
- $cacheFile
- The path of the cache file, relative to CACHE_DIR
Returns
boolean True if the file cached, else false
|
public
string
|
#
getCacheContent( string $cacheFile )
Get the content of a cache file
Get the content of a cache file
Parameters
- $cacheFile
- The path of the cache file
Returns
string The content of the cache file
|
public
mixed
|
#
includeCache( string $cacheFile )
Include a cache file
Parameters
- $cacheFile
- The cache file to include
Returns
mixed The data returned in the cache file
|
public
|
#
save( string $cacheFile, string $content )
Save data in a cache file
Save data in a cache file
Parameters
- $cacheFile
- The path of the cache file, relative to CACHE_DIR
- $content
- The content to write in the cache file
|
public
|
#
clear( string $cacheFile = '*' )
Clear a cache file or directory
Clear a cache file or directory
Parameters
- $cacheFile
- The cache file or directory to clear
|