TemplateCacheService

Type
Class
Namespace
Craft
Inherits
Craft\TemplateCacheService » Craft\BaseApplicationComponent » CApplicationComponent » CComponent
Implements
IApplicationComponent
Since
2.0

Class TemplateCacheService

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$behaviorsarray – The behaviors that should be attached to this component.

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
canGetProperty()Determines whether a property can be read.
canSetProperty()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()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
endTemplateCache()Ends a template cache.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
getEventHandlers()Returns the list of attached event handlers for an event.
getIsInitialized()Checks if this application component has been initialized.
getTemplateCache()Returns a cached template by its key.
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
includeCriteriaInTemplateCaches()Includes an element criteria in any active caches.
includeElementInTemplateCaches()Includes an element in any active caches.
init()Initializes the application component.
isInitialized()Checks if this application component has been initialized yet, or not.
raiseEvent()Raises an event.
startTemplateCache()Starts a new template cache.

deleteAllCaches()

Deletes all the template caches.

View source

Returns

boolean

Signature

public boolean deleteAllCaches ( )

deleteCacheById()

Deletes a cache by its ID(s).

View source

Arguments

Returns

boolean

Signature

public boolean deleteCacheById ( $cacheId )

deleteCachesByCriteria()

Deletes caches that include elements that match a given criteria.

View source

Arguments

Returns

boolean

Signature

public boolean deleteCachesByCriteria ( Craft\ElementCriteriaModel $criteria )

deleteCachesByElement()

Deletes caches that include a given element(s).

View source

Arguments

Returns

boolean

Signature

public boolean deleteCachesByElement ( $elements )

deleteCachesByElementId()

Deletes caches that include an a given element ID(s).

View source

Arguments

  • $elementId (integer, array) – The ID of the element(s) whose caches should be cleared.
  • $deleteQueryCaches (boolean) – Whether a DeleteStaleTemplateCaches task should be created, deleting any query caches that may now involve this element, but hadn't previously. (Defaults to true.)

Returns

boolean

Throws

Signature

public boolean deleteCachesByElementId ( $elementId, $deleteQueryCaches = true )

deleteCachesByElementType()

Deletes caches by a given element type.

View source

Arguments

  • $elementType (string) – The element type handle.

Returns

boolean

Signature

public boolean deleteCachesByElementType ( $elementType )

deleteCachesByKey()

Deletes a cache by its key(s).

View source

Arguments

Returns

boolean

Signature

public boolean deleteCachesByKey ( $key )

deleteExpiredCaches()

Deletes any expired caches.

View source

Returns

boolean

Signature

public boolean deleteExpiredCaches ( )

deleteExpiredCachesIfOverdue()

Deletes any expired caches if we haven't already done that within the past 24 hours.

View source

Returns

boolean

Signature

public boolean deleteExpiredCachesIfOverdue ( )

endTemplateCache()

Ends a template cache.

View source

Arguments

  • $key (string) – The template cache key.
  • $global (boolean) – Whether the cache should be stored globally.
  • $duration (string, null) – How long the cache should be stored for.
  • $expiration (mixed, null) – When the cache should expire.
  • $body (string) – The contents of the cache.

Returns

null

Throws

Signature

public null endTemplateCache ( $key, $global, $duration, $expiration, $body )

getTemplateCache()

Returns a cached template by its key.

View source

Arguments

  • $key (string) – The template cache key
  • $global (boolean) – Whether the cache would have been stored globally.

Returns

string, null

Signature

public string, null getTemplateCache ( $key, $global )

includeCriteriaInTemplateCaches()

Includes an element criteria in any active caches.

View source

Arguments

Returns

null

Signature

public null includeCriteriaInTemplateCaches ( Craft\ElementCriteriaModel $criteria )

includeElementInTemplateCaches()

Includes an element in any active caches.

View source

Arguments

  • $elementId (integer) – The element ID.

Returns

null

Signature

public null includeElementInTemplateCaches ( $elementId )

startTemplateCache()

Starts a new template cache.

View source

Arguments

  • $key (string) – The template cache key.

Returns

null

Signature

public null startTemplateCache ( $key )