Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

ezcache.php

Summary

Clears the eZ Publish caches.

Location

./bin/php/ezcache.php

Parameters

allow-root-user
clear-all
clear-id
clear-tag
colors
debug
expiry
help
iteration-max
iteration-sleep
list-ids
list-tags
logfiles
no-colors
no-logfiles
purge
quiet
siteaccess
verbose

-r,--allow-root-user

Allows your root user to run the ezcache.php script. The usage of this parameter is only recommended for advanced users. With great power comes great responsibility.

--clear-all

Clears all caches. This parameter can be useful if you want to clean all caches instead of deleting a particular cache tag or identifier.

--clear-id=<cache_id>[,<cache_id2>…]

Expire all caches of a particular type specified by "cache_id". Multiple identifiers can be provided as a comma separated list. When combined with the "--purge" parameter, the script will clear the caches instead of expiring them.

Note that there are dependencies between caches, and that clearing only one ID will most likely require that other caches are cleared as well. Example: clearing the ezjscore-packer cache will require that templte-cache is cleared as well, since ezjscore is used within cache blocks.

--clear-tag=<cache_tag>[,<cache_tag2>...]

Expire all caches related to the specified cache tag.

From eZ Publish 5.3.4 version, multiple tags can be provided as a comma separated list. When combined with the "--purge" parameter, the script will clear the caches instead of expiring them.

-c, --colors

Use ANSI colors when generating debug output (default).

-d[<option>[,<option2>...]], --debug[=<option>[,<option2>...]]

Output debug information. The following options can be used to control what the debug output should include: "all" (everything), "accumulator" (accumulators), "include" (included files), "timing" (timing points), "error" (errors), "warning" (warnings), "notice" (notices).

--expiry=<textual_date_format>

Expire caches that are older than the specified date. The date must be provided according to the GNU Date Input Formats syntax. This can only be used together with the "--purge" parameter, which means the script will delete the caches.

-h, --help

Output information about the script and supported parameters.

--iteration-max=<number_of_items>

The maximum number of items to remove during one iteration of cache purging.

--iteration-sleep=<number_of_seconds>

The number of seconds to wait between cache purge iterations.

--list-ids

Output a list of cache type identifiers that are supported by the "--clear-id" parameter. When used together with the "--verbose" parameter, the script will output additional information about the cache types and their identifiers.

--list-tags

Output a list of cache tags that are supported by the "--clear-tag" parameter. When used together with the "--verbose" parameter, the script will output additional information about the cache tags.

--logfiles

Generate log files. This parameter must be used together with the debug parameter ("-d" or "--debug"). The log files (for example "warning.log") will be stored in the "var/log" directory of the eZ Publish installation.

--no-colors

Do not use ANSI colors when generating debug output.

--no-logfiles

Do not generate log files (default).

--purge

Enforces purging of cache items, DELETING the entries from the database and the cache files from file system, which ensures that specified entries are physically removed (Useful for saving disk space). This parameter must be used together with "--clear-all", "--clear-id", "--clear-tag" or "--expiry".

-q, --quiet

Run the script in "quiet" mode. No output will be generated.

-s <siteaccess>, --siteaccess=<siteaccess>

The siteaccess to run the script for. If omitted, the default siteaccess will be used.

-v, --verbose

Output verbose / additional information.

Description

This script makes it possible to clear various eZ Publish caches - that is, either expire the specified caches (default) or physically remove the cache files (requires the "--purge" parameter).

To run the script, navigate into the root directory of your eZ Publish installation and use the following shell command:

php bin/php/ezcache.php [<parameters>]

Replace "[<parameters>]" with one or more of the script parameters described above. Note that you need to have PHP CLI installed in order to run the script from within a system shell.

Sometimes the script is unable to clear the caches because of restrictive file/directory permission settings. You can check whether the caches have been cleared by inspecting the contents of the various cache subdirectories within the "var" directory (typically "var/cache/" and "var/<name_of_siteaccess>/cache/" directories).

Selective cache cleanup

eZ Publish generates different types of caches. While the "--clear-all" parameter gets rid of everything, the "--clear-id" parameter makes it possible to remove only certain types of caches (configuration settings, compiled templates, URL aliases, image variations, etc.). The identifiers of the caches to be removed must be specified as a comma separated list.

A "cache tag" is assigned to every cache type. The cache tag reveals which group a particular cache belongs to (ini, image, template, content and so on). The "--clear-tag" parameter makes it possible to clear all caches that belong to a specified group. Note that a cache type (for example, the "Template block cache") can be assigned to several groups.

The following table shows the different caches, the corresponding identifiers and cache tags (the group they belong to).

Name

Identifier

Cache tags

Active extensions cache

active_extensions

ini

INI cache

ini

ini

Global INI cache

global_ini

ini

SSL Zones cache

sslzones

ini

Image alias cache

imagealias

image

Template cache

template

template

Template override cache

template-override

template

Text to image cache

texttoimage

template

Design base cache

design_base

template

eZJSCore Public Packer cache

ezjscore-packer

template

Template block cache

template-block

template, content

Content view cache

content

content

URL alias cache

urlalias

content

RSS cache

rss_cache

content

Class identifier cache

classid

content

Sort key cache

sortkey

content

Content tree menu (browser cache)

content_tree_menu

content

State limitations cache

state_limitations

content

User info cache

user_info_cache

user

Codepage cache

codepage

codepage

Character transformation cache

chartrans

i18n

TS Translation cache

translation

i18n

REST Application cache

rest

rest

REST Routes memory cache

rest-routes

rest

Clustering compatibility

The script also works if the caches are stored in the database (typically happens when running eZ Publish in a cluster environment). When the "--purge" parameter is specified, the cache entries are DELETED from the tables. When it is not specified, the system will only mark the entries as expired either using UPDATE queries or using the expiry values in "expiry.php".

Please note that in a cluster environment the ezcache.php script will need to be executed on each cluster node in order to remove the local cache on each one. For this task the usage the of the parameters and --purge is advised, used together with the clear-* options you desire.

Examples

Example 1

php bin/php/ezcache.php --clear-all

Expire all caches.

Example 2

php bin/php/ezcache.php --clear-all --purge

Clear all caches (either physically remove all cache files or delete all cache entries from the database).

Example 3

php bin/php/ezcache.php --clear-all --purge -dwarning

Clear all caches and output warnings that occur during execution. For example, if the system is not able to locate one of the enabled extensions, the console output could look like this:

Purging : Content view cache, Global INI cache, INI cache, Codepage cache, Class identifier cache, Sort key cache, URL alias cache, Character transformation cache, Image alias, Template cache, Template block cache, Template override cache, RSS cache, User info cache, Content tree menu (browser cache)
 
################### DEBUG ###################
Warning: ()
Extension 'ezdhtml' does not exist, looked for directory 'extension/ezdhtml'

Example 4

php bin/php/ezcache.php --clear-id=user_info_cache

Expire all user info caches.

Example 5

php bin/php/ezcache.php --clear-tag=ini --purge

Clear both INI cache and global INI cache.

Example 6

php bin/php/ezcache.php --clear-all --iteration-sleep='5.5'
--iteration-max=100 --purge

Clear all caches. The purging will be done with the interval between the iterations equal to 5.5 seconds. During one iteration, a maximum number of 100 items will be removed.

Example 7

php bin/php/ezcache.php --expiry='-2 days' --purge

Clear all caches that are older than two days.

Example 8

php bin/php/ezcache.php --expiry='last monday' --purge

Clear all caches generated before last Monday.

Julia Shymova (01/11/2007 1:57 pm)

Sarah Haïm-Lubczanski (30/06/2015 2:07 pm)

Julia Shymova, Svitlana Shatokhina, Ricardo Correia, Sarah Haïm-Lubczanski


Comments

There are no comments.