TemplateCacheService
- Type
- Class
- Namespace
- Craft
- Inherits
- Craft\TemplateCacheService » Craft\BaseApplicationComponent » CApplicationComponent (opens new window) » CComponent (opens new window)
- Implements
IApplicationComponent- Since
- 2.0
Class TemplateCacheService
See also http://craftcms.com
View source (opens new window)
# Public Properties
| Property | Description |
|---|---|
| $behaviors (opens new window) | array (opens new window) – The behaviors that should be attached to this component. |
# Public Methods
| Method | Description |
|---|---|
| __call() (opens new window) | Calls the named method which is not a class method. |
| __get() (opens new window) | Returns a property value, an event handler list or a behavior based on its name. |
| __isset() (opens new window) | Checks if a property value is null. |
| __set() (opens new window) | Sets value of a component property. |
| __unset() (opens new window) | Sets a component property to be null. |
| asa() (opens new window) | Returns the named behavior object. |
| attachBehavior() (opens new window) | Attaches a behavior to this component. |
| attachBehaviors() (opens new window) | Attaches a list of behaviors to the component. |
| attachEventHandler() (opens new window) | Attaches an event handler to an event. |
| canGetProperty() (opens new window) | Determines whether a property can be read. |
| canSetProperty() (opens new window) | Determines whether a property can be set. |
| deleteAllCaches() | Deletes all the template caches. |
| deleteCacheById() | Deletes a cache by its ID(s). |
| deleteCachesByCriteria() | Deletes caches that include elements that match a given criteria. |
| deleteCachesByElement() | Deletes caches that include a given element(s). |
| deleteCachesByElementId() | Deletes caches that include an a given element ID(s). |
| deleteCachesByElementType() | Deletes caches by a given element type. |
| deleteCachesByKey() | Deletes a cache by its key(s). |
| deleteExpiredCaches() | Deletes any expired caches. |
| deleteExpiredCachesIfOverdue() | Deletes any expired caches if we haven't already done that within the past 24 hours. |
| detachBehavior() (opens new window) | Detaches a behavior from the component. |
| detachBehaviors() (opens new window) | Detaches all behaviors from the component. |
| detachEventHandler() (opens new window) | Detaches an existing event handler. |
| disableBehavior() (opens new window) | Disables an attached behavior. |
| disableBehaviors() (opens new window) | Disables all behaviors attached to this component. |
| enableBehavior() (opens new window) | Enables an attached behavior. |
| enableBehaviors() (opens new window) | Enables all behaviors attached to this component. |
| endTemplateCache() | Ends a template cache. |
| evaluateExpression() (opens new window) | Evaluates a PHP expression or callback under the context of this component. |
| getEventHandlers() (opens new window) | Returns the list of attached event handlers for an event. |
| getIsInitialized() (opens new window) | Checks if this application component has been initialized. |
| getTemplateCache() | Returns a cached template by its key. |
| hasEvent() (opens new window) | Determines whether an event is defined. |
| hasEventHandler() (opens new window) | Checks whether the named event has attached handlers. |
| hasProperty() (opens new window) | Determines whether a property is defined. |
| includeCriteriaInTemplateCaches() | Includes an element criteria in any active caches. |
| includeElementInTemplateCaches() | Includes an element in any active caches. |
| init() (opens new window) | Initializes the application component. |
| isInitialized() | Checks if this application component has been initialized yet, or not. |
| raiseEvent() (opens new window) | Raises an event. |
| startTemplateCache() | Starts a new template cache. |
# deleteAllCaches()
Signature
public boolean deleteAllCaches ( )
# deleteCacheById()
Deletes a cache by its ID(s).
View source (opens new window)
Arguments
$cacheId(integer (opens new window), array (opens new window)) – The cache ID.
Returns
Signature
public boolean deleteCacheById ( $cacheId )
# deleteCachesByCriteria()
Deletes caches that include elements that match a given criteria.
View source (opens new window)
Arguments
$criteria(Craft\ElementCriteriaModel) – The criteria that should be used to find elements whose caches should be deleted.
Returns
Signature
public boolean deleteCachesByCriteria ( Craft\ElementCriteriaModel $criteria )
# deleteCachesByElement()
Deletes caches that include a given element(s).
View source (opens new window)
Arguments
$elements(Craft\BaseElementModel, Craft\BaseElementModel[]) – The element(s) whose caches should be deleted.
Returns
Signature
public boolean deleteCachesByElement ( $elements )
# deleteCachesByElementId()
Deletes caches that include an a given element ID(s).
View source (opens new window)
Arguments
$elementId(integer (opens new window), array (opens new window)) – The ID of the element(s) whose caches should be cleared.$deleteQueryCaches(boolean (opens new window)) – Whether a DeleteStaleTemplateCaches task should be created, deleting any query caches that may now involve this element, but hadn't previously. (Defaults totrue.)
Returns
Throws
Signature
public boolean deleteCachesByElementId ( $elementId, $deleteQueryCaches = true )
# deleteCachesByElementType()
Deletes caches by a given element type.
View source (opens new window)
Arguments
$elementType(string (opens new window)) – The element type handle.
Returns
Signature
public boolean deleteCachesByElementType ( $elementType )
# deleteCachesByKey()
Deletes a cache by its key(s).
View source (opens new window)
Arguments
$key(integer (opens new window), array (opens new window)) – The cache key(s) to delete.
Returns
Signature
public boolean deleteCachesByKey ( $key )
# deleteExpiredCaches()
Signature
public boolean deleteExpiredCaches ( )
# deleteExpiredCachesIfOverdue()
Deletes any expired caches if we haven't already done that within the past 24 hours.
View source (opens new window)
Returns
Signature
public boolean deleteExpiredCachesIfOverdue ( )
# endTemplateCache()
Ends a template cache.
View source (opens new window)
Arguments
$key(string (opens new window)) – The template cache key.$global(boolean (opens new window)) – Whether the cache should be stored globally.$duration(string (opens new window), null (opens new window)) – How long the cache should be stored for.$expiration(mixed, null (opens new window)) – When the cache should expire.$body(string (opens new window)) – The contents of the cache.
Returns
Throws
Signature
public null endTemplateCache ( $key, $global, $duration, $expiration, $body )
# getTemplateCache()
Returns a cached template by its key.
View source (opens new window)
Arguments
$key(string (opens new window)) – The template cache key$global(boolean (opens new window)) – Whether the cache would have been stored globally.
Returns
Signature
public string, null getTemplateCache ( $key, $global )
# includeCriteriaInTemplateCaches()
Includes an element criteria in any active caches.
View source (opens new window)
Arguments
$criteria(Craft\ElementCriteriaModel) – The element criteria.
Returns
Signature
public null includeCriteriaInTemplateCaches ( Craft\ElementCriteriaModel $criteria )
# includeElementInTemplateCaches()
Includes an element in any active caches.
View source (opens new window)
Arguments
$elementId(integer (opens new window)) – The element ID.
Returns
Signature
public null includeElementInTemplateCaches ( $elementId )
# startTemplateCache()
Starts a new template cache.
View source (opens new window)
Arguments
$key(string (opens new window)) – The template cache key.
Returns
Signature
public null startTemplateCache ( $key )