TemplateCaches

Type
Class
Namespace
craft\services
Inherits
craft\services\TemplateCaches » yii\base\Component (opens new window) » yii\base\BaseObject (opens new window)
Implements
yii\base\Configurable (opens new window)
Since
3.0.0

Template Caches service.

An instance of the Template Caches service is globally accessible in Craft via Craft::$app->templateCaches.

View source (opens new window)

# Public Properties

Property Description
behaviors (opens new window) yii\base\Behavior (opens new window) – List of behaviors attached to this component

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__clone() (opens new window) This method is called after the object is created by cloning an existing one.
__construct() (opens new window) Constructor.
__get() (opens new window) Returns the value of an object property.
__isset() (opens new window) Checks if a property is set, i.e. defined and not null.
__set() (opens new window) Sets value of an object property.
__unset() (opens new window) Sets an object property to null.
attachBehavior() (opens new window) Attaches a behavior to this component.
attachBehaviors() (opens new window) Attaches a list of behaviors to the component.
behaviors() (opens new window) Returns a list of behaviors that this component should behave as.
canGetProperty() (opens new window) Returns a value indicating whether a property can be read.
canSetProperty() (opens new window) Returns a value indicating whether a property can be set.
className() (opens new window) Returns the fully qualified name of this class.
deleteAllCaches() Deletes all the template caches.
deleteCacheById() Deletes a cache by its ID(s).
deleteCachesByElement() Deletes caches that include a given element(s).
deleteCachesByElementId() Deletes caches that include an a given element ID(s).
deleteCachesByElementQuery() Deletes caches that include elements that match a given element query's parameters.
deleteCachesByElementType() Deletes caches by a given element class.
deleteCachesByKey() Deletes a cache by its key(s).
deleteExpiredCaches() Deletes any expired caches.
deleteExpiredCachesIfOverdue() Deletes any expired caches.
detachBehavior() (opens new window) Detaches a behavior from the component.
detachBehaviors() (opens new window) Detaches all behaviors from the component.
endTemplateCache() Ends a template cache.
ensureBehaviors() (opens new window) Makes sure that the behaviors declared in behaviors() (opens new window) are attached to this component.
getBehavior() (opens new window) Returns the named behavior object.
getBehaviors() (opens new window) Returns all behaviors attached to this component.
getTemplateCache() Returns a cached template by its key.
handleResponse() Queues up a Delete Stale Template Caches job
hasEventHandlers() (opens new window) Returns a value indicating whether there is any handler attached to the named event.
hasMethod() (opens new window) Returns a value indicating whether a method is defined.
hasProperty() (opens new window) Returns a value indicating whether a property is defined.
includeElementInTemplateCaches() Includes an element in any active caches.
includeElementQueryInTemplateCaches() Includes an element criteria in any active caches.
init() (opens new window) Initializes the object.
off() (opens new window) Detaches an existing event handler from this component.
on() (opens new window) Attaches an event handler to an event.
startTemplateCache() Starts a new template cache.
trigger() (opens new window) Triggers an event.

# deleteAllCaches()

DEPRECATED

Deprecated in 3.5.0. Use craft\services\Elements::invalidateAllCaches() instead.

Deletes all the template caches.

View source (opens new window)

Returns

boolean (opens new window)

# deleteCacheById()

DEPRECATED

Deprecated in 3.5.0

Deletes a cache by its ID(s).

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# deleteCachesByElement()

DEPRECATED

Deprecated in 3.5.0. Use craft\services\Elements::invalidateCachesForElement() instead.

Deletes caches that include a given element(s).

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# deleteCachesByElementId()

DEPRECATED

Deprecated in 3.5.0. Use craft\services\Elements::invalidateCachesForElement() instead.

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

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# deleteCachesByElementQuery()

DEPRECATED

Deprecated in 3.5.0. Use craft\services\Elements::invalidateCachesForElementType() instead.

Deletes caches that include elements that match a given element query's parameters.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# deleteCachesByElementType()

DEPRECATED

Deprecated in 3.5.0. Use craft\services\Elements::invalidateCachesForElementType() instead.

Deletes caches by a given element class.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# deleteCachesByKey()

Deletes a cache by its key(s).

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# deleteExpiredCaches()

DEPRECATED

Deprecated in 3.5.0

Deletes any expired caches.

View source (opens new window)

Returns

boolean (opens new window)

# deleteExpiredCachesIfOverdue()

DEPRECATED

Deprecated in 3.2.0

Deletes any expired caches.

View source (opens new window)

Returns

boolean (opens new window)

# endTemplateCache()

Ends a template cache.

View source (opens new window)

Arguments

Throws

# getTemplateCache()

Returns a cached template by its key.

View source (opens new window)

Arguments

Returns

string (opens new window), null (opens new window)

# handleResponse()

DEPRECATED

Deprecated in 3.5.0

Queues up a Delete Stale Template Caches job

View source (opens new window)

# includeElementInTemplateCaches()

DEPRECATED

Deprecated in 3.5.0

Includes an element in any active caches.

View source (opens new window)

Arguments

# includeElementQueryInTemplateCaches()

DEPRECATED

Deprecated in 3.5.0

Includes an element criteria in any active caches.

View source (opens new window)

Arguments

# startTemplateCache()

Starts a new template cache.

View source (opens new window)

# Events

# EVENT_AFTER_DELETE_CACHES

DEPRECATED

Deprecated in 3.5.0

Type
\craft\services\SectionEvent
Since
3.0.2

The event that is triggered after template caches are deleted.

# EVENT_BEFORE_DELETE_CACHES

DEPRECATED

Deprecated in 3.5.0

Type
\craft\services\SectionEvent
Since
3.0.2

The event that is triggered before template caches are deleted.