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

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

--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.

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

Expire all caches related to the specified cache tag. 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. When combined with the "--purge" parameter, the script will clear the caches instead of expiring them.

-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

Remove the cache files or DELETE the corresponding cache entries if the caches are stored in the database. 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

INI cache

ini

ini

Global INI cache

global_ini

ini

Image alias cache

imagealias

image

Template cache

template

template

Template override cache

template-override

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

Tree menu cache

content_tree_menu

content

User info cache

user_info_cache

user

Codepage cache

codepage

codepage

Character transformation cache

chartrans

i18n

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".

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'

Expire 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)

Svitlana Shatokhina (22/05/2008 10:15 am)

Julia Shymova, Svitlana Shatokhina


Comments

There are no comments.