Cache class to cache the HTML results for actions and templates.
Method Summary
-
addCache($moduleName, $actionName, $options = array())
Adds a cache to the manager.
-
string
checkCacheKey(&$parameters, $parameters)
Checks that the supplied parameters include a cache key.
-
computeCacheKey($parameters)
Computes the cache key based on the passed parameters.
-
string
convertParametersToKey($params)
Transforms an associative array of parameters from an URI into a unique key
-
string
decorateContentWithDebug($event, $content)
Listens to the 'view.cache.filter_content' event to decorate a
chunk of HTML with cache information.
-
string
generateCacheKey($internalUri, $hostName = '', $vary = '', $contextualPrefix = '')
Generates a unique cache key for an internal URI.
-
string
get($internalUri)
Retrieves content in the cache.
-
array
getActionCache($uri)
Gets an action template from the cache.
-
getCache()
Retrieves the current cache object.
-
mixed
getCacheConfig($internalUri, $key, $defaultValue = null)
Gets a config option from the cache.
-
int
getClientLifeTime($internalUri)
Retrieves client lifetime from the cache option list
-
getContext()
Retrieves the current cache context.
-
int
getLastModified($internalUri)
Retrieves the last modified time.
-
int
getLifeTime($internalUri)
Retrieves lifetime from the cache option list.
-
string
getPageCache($uri)
Gets a page from the cache.
-
string
getPartialCache($module, $action, $cacheKey)
Gets a partial template from the cache.
-
string
getPartialUri($module, $action, $cacheKey)
Computes a partial internal URI.
-
int
getTimeout($internalUri)
Retrieves the timeout.
-
array
getVary($internalUri)
Retrieves vary option from the cache option list.
-
bool
has($internalUri)
Returns true if there is a cache.
-
bool
hasActionCache($uri)
Returns whether an action template is in the cache.
-
bool
hasPartialCache($module, $action, $cacheKey)
Returns whether a partial template is in the cache.
-
bool
ignore()
Ignores the cache functionality.
-
initialize((sfContext) $context, $cache)
Initializes the cache manager.
-
boolean
isActionCacheable($moduleName, $actionName)
Returns true if the action is cacheable.
-
bool
isCacheable($internalUri)
Returns true if the current content is cacheable.
-
boolean
isContextual($internalUri)
Retrieves contextual option from the cache option list.
-
registerConfiguration($moduleName)
Registers configuration options for the cache.
-
bool
remove($internalUri, $hostName = '', $vary = '', $contextualPrefix = '**')
Removes the content in the cache.
-
boolean
set($data, $internalUri)
Sets the cache content.
-
string
setActionCache($uri, $content, $decoratorTemplate)
Sets an action template in the cache.
-
setPageCache($uri)
Sets a page in the cache.
-
string
setPartialCache($module, $action, $cacheKey, $content)
Sets an action template in the cache.
-
bool
start($name, $lifeTime, $clientLifeTime = null, $vary = array())
Starts the fragment cache.
-
bool
stop($name)
Stops the fragment cache.
-
bool
withLayout($internalUri)
Retrieves the layout from the cache option list.
-
__construct($context, $cache)
Class constructor.
Method Details
-
addCache ($moduleName, $actionName, $options = array())
Browse code
| $moduleName |
Module name
|
| $actionName |
Action name
|
| $options |
Options for the cache
|
Adds a cache to the manager.
-
(string) checkCacheKey (&$parameters, $parameters)
Browse code
| &$parameters |
|
| $parameters |
An array of parameters
|
Checks that the supplied parameters include a cache key.
If no 'sf_cache_key' parameter is present one is added to the array as it is passed by reference.
returns The cache key
-
computeCacheKey ($parameters)
Browse code
| $parameters |
An array of parameters
|
Computes the cache key based on the passed parameters.
-
(string) convertParametersToKey ($params)
Browse code
| $params |
Associative array of parameters from the URI (including, at least, module
and action)
|
Transforms an associative array of parameters from an URI into a unique key
returns Unique key
-
(string) decorateContentWithDebug ($event, $content)
Browse code
| $event |
A sfEvent instance
|
| $content |
The HTML content
|
Listens to the 'view.cache.filter_content' event to decorate a
chunk of HTML with cache information.
returns The decorated HTML string
-
(string) generateCacheKey ($internalUri, $hostName = '', $vary = '', $contextualPrefix = '')
Browse code
| $internalUri |
The internal unified resource identifier
Accepts rules formatted like
'module/action?key1=value1&key2=value2'
Does not accept rules starting with a route name, except for
'@sf_cache_partial'
|
| $hostName |
The host name Optional - defaults to the
current host name bu default
|
| $vary |
The vary headers, separated by |, or "all" for all vary headers
Defaults to 'all'
|
| $contextualPrefix |
The contextual prefix for contextual partials.
Defaults to
'currentModule/currentAction/currentPAram1/currentvalue1'
Used only by the sfViewCacheManager::remove()
method
|
Generates a unique cache key for an internal URI.
This cache key can be used by any of the cache engines as a unique identifier to a cached resource Basically, the cache key generated for the following internal URI: module/action?key1=value1&key2=value2 Looks like: /localhost/all/module/action/key1/value1/key2/value2
returns The cache key If some of the parameters contained wildcards (* or **), the generated key will also have wildcards
-
(string) get ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Retrieves content in the cache.
returns The content in the cache
-
(array) getActionCache ($uri)
Browse code
Gets an action template from the cache.
returns An array composed of the cached content and the view attribute holder
-
Retrieves the current cache object.
returns The current cache object
-
(mixed) getCacheConfig ($internalUri, $key, $defaultValue = null)
Browse code
| $internalUri |
Internal uniform resource identifier
|
| $key |
Option name
|
| $defaultValue |
Default value of the option
|
Gets a config option from the cache.
returns Value of the option
-
(int) getClientLifeTime ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Retrieves client lifetime from the cache option list
returns Client lifetime
-
Retrieves the current cache context.
returns The sfContext instance
-
(int) getLastModified ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Retrieves the last modified time.
returns The last modified datetime
-
(int) getLifeTime ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Retrieves lifetime from the cache option list.
returns LifeTime
-
(string) getPageCache ($uri)
Browse code
Gets a page from the cache.
returns The cached page
-
(string) getPartialCache ($module, $action, $cacheKey)
Browse code
| $module |
The module name
|
| $action |
The action name
|
| $cacheKey |
The cache key
|
Gets a partial template from the cache.
returns The cache content
-
(string) getPartialUri ($module, $action, $cacheKey)
Browse code
| $module |
The module name
|
| $action |
The action name
|
| $cacheKey |
The cache key
|
Computes a partial internal URI.
returns The internal URI
-
(int) getTimeout ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Retrieves the timeout.
returns The timeout datetime
-
(array) getVary ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Retrieves vary option from the cache option list.
returns Vary options for the cache
-
(bool) has ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Returns true if there is a cache.
returns true, if there is a cache otherwise false
-
(bool) hasActionCache ($uri)
Browse code
Returns whether an action template is in the cache.
returns true if an action is in the cache, false otherwise
-
(bool) hasPartialCache ($module, $action, $cacheKey)
Browse code
| $module |
The module name
|
| $action |
The action name
|
| $cacheKey |
The cache key
|
Returns whether a partial template is in the cache.
returns true if a partial is in the cache, false otherwise
-
Ignores the cache functionality.
returns true, if the cache is ignore otherwise false
-
initialize ((sfContext) $context, $cache)
Browse code
| $context |
Current application context
|
| $cache |
An sfCache instance
|
Initializes the cache manager.
-
(boolean) isActionCacheable ($moduleName, $actionName)
Browse code
| $moduleName |
A module name
|
| $actionName |
An action or partial template name
|
Returns true if the action is cacheable.
returns True if the action is cacheable
-
(bool) isCacheable ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Returns true if the current content is cacheable.
Possible break in backward compatibility: If the sf_lazy_cache_key setting is turned on in settings.yml, this method is not used when initially checking a partial's cacheability.
returns true, if the content is cacheable otherwise false
-
(boolean) isContextual ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Retrieves contextual option from the cache option list.
returns true, if is contextual otherwise false
-
registerConfiguration ($moduleName)
Browse code
Registers configuration options for the cache.
-
(bool) remove ($internalUri, $hostName = '', $vary = '', $contextualPrefix = '**')
Browse code
| $internalUri |
Internal uniform resource identifier
|
| $hostName |
The host name
|
| $vary |
The vary headers, separated by |, or "all" for all vary headers
|
| $contextualPrefix |
The removal prefix for contextual partials. Defaults to '**' (all
actions, all params)
|
Removes the content in the cache.
returns true, if the remove happened, false otherwise
-
(boolean) set ($data, $internalUri)
Browse code
| $data |
Data to put in the cache
|
| $internalUri |
Internal uniform resource identifier
|
Sets the cache content.
returns true, if the data get set successfully otherwise false
-
(string) setActionCache ($uri, $content, $decoratorTemplate)
Browse code
| $uri |
The internal URI
|
| $content |
The content to cache
|
| $decoratorTemplate |
The view attribute holder to cache
|
Sets an action template in the cache.
returns The cached content
-
Sets a page in the cache.
-
(string) setPartialCache ($module, $action, $cacheKey, $content)
Browse code
| $module |
The module name
|
| $action |
The action name
|
| $cacheKey |
The cache key
|
| $content |
The content to cache
|
Sets an action template in the cache.
returns The cached content
-
(bool) start ($name, $lifeTime, $clientLifeTime = null, $vary = array())
Browse code
| $name |
Unique fragment name
|
| $lifeTime |
Life time for the cache
|
| $clientLifeTime |
Client life time for the cache
|
| $vary |
Vary options for the cache
|
Starts the fragment cache.
returns true, if success otherwise false
-
| $name |
Unique fragment name
|
Stops the fragment cache.
returns true, if success otherwise false
-
(bool) withLayout ($internalUri)
Browse code
| $internalUri |
Internal uniform resource identifier
|
Retrieves the layout from the cache option list.
returns true, if have layout otherwise false
-
__construct ($context, $cache)
Browse code
Class constructor.
|