kernel/classes/ezstaticcache.php
File containing the eZStaticCache class
- Copyright
- Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
- License
- eZ Business Use License Agreement Version 2.0
- Package
- kernel
- Version
- 4.6.0
\eZStaticCache
The eZStaticCache class manages the static cache system.
This class can be used to generate static cache files usable by the static cache system.
Generating static cache is done by instantiating the class and then calling generateCache(). For example:
$staticCache = new eZStaticCache();
$staticCache->generateCache();
To generate the URLs that must always be updated call generateAlwaysUpdatedCache()
- Parent(s)
- \ezpStaticCache
Constants
Properties

\array(int=>string)
$alwaysUpdate= ''
An array with URLs that is to always be updated.
- Type
- \array(int=>string)

\array(int=>string)
$cachedSiteAccesses= 'array()'
An array with siteaccesses names that will be cached.
array()Details- Type
- \array(int=>string)

\array(int=>string)
$cachedURLArray= 'array()'
Array of URLs to cache.
array()Details- Type
- \array(int=>string)

string
$hostName= ''
The name of the host to fetch HTML data from.
- Type
- string
- Deprecated
- deprecated since version 4.4, site.ini.[SiteSettings].SiteURL is used instead
Methods

addAction(
string $action, array $parameters
)
:
voidThis function adds an action to the list that is used at the end of the request to remove and regenerate static cache files.
| Name | Type | Description |
|---|---|---|
| $action | string | |
| $parameters | array |

alwaysUpdateURLArray(
)
:
arrayGetter method for {@link eZStaticCache::$alwaysUpdate}
These URLs are configured with AlwaysUpdateArray in staticcache.ini.
| Type | Description |
|---|---|
| array | An array with URLs that is to always be updated. |

buildCacheDirPart(
string $dir, string $siteAccess
)
:
arrayA helper method used to create directory parts array
| Name | Type | Description |
|---|---|---|
| $dir | string | |
| $siteAccess | string |
| Type | Description |
|---|---|
| array |

buildCacheDirPath(
string $siteAccess
)
:
arrayGenerates a cache directory parts including path, siteaccess name, site URL depending on the match order type.
| Name | Type | Description |
|---|---|---|
| $siteAccess | string |
| Type | Description |
|---|---|
| array |

buildCacheFilename(
string $staticStorageDir, string $url
)
:
stringGenerates a full path to the cache file (index.html) based on the input parameters.
| Name | Type | Description |
|---|---|---|
| $staticStorageDir | string | The storage for cache files. |
| $url | string | The URL for the current item, e.g /news |
| Type | Description |
|---|---|
| string | The full path to the cache file (index.html). |

cacheURL(
string $url, int | false $nodeID
=
false, bool $skipExisting
=
false, $delay
=
true
)
:
boolGenerates the caches for the url $url using the currently configured storageDirectory().
| Name | Type | Description |
|---|---|---|
| $url | string | The URL to cache, e.g /news |
| $nodeID | int | false | The ID of the node to cache, if supplied it will also cache content/view/full/xxx. |
| $skipExisting | bool | If true it will not unlink existing cache files. |
| $delay |
| Type | Description |
|---|---|
| bool |

cachedSiteAccesses(
)
:
arrayGetter method for {@link eZStaticCache::$cachedSiteAccesses}
| Type | Description |
|---|---|
| array | An array with site-access names that should be cached. |

cachedURLArray(
)
:
arrayGetter method for {@link eZStaticCache::$cachedURLArray}
| Type | Description |
|---|---|
| array | An array with URLs that is to be cached statically, the URLs may contain wildcards. |

executeActions(
)
:
voidThis function goes over the list of recorded actions and excecutes them.

generateAlwaysUpdatedCache(
bool $quiet
=
false, \eZCLI | false $cli
=
false, bool $delay
=
true
)
:
voidGenerates the caches for all URLs that must always be generated.
| Name | Type | Description |
|---|---|---|
| $quiet | bool | If true then the function will not output anything. |
| $cli | \eZCLI | false | The eZCLI object or false if no output can be done. |
| $delay | bool |

generateCache(
bool $force
=
false, bool $quiet
=
false, \eZCLI | false $cli
=
false, bool $delay
=
true
)
:
voidGenerates the static cache from the configured INI settings.
| Name | Type | Description |
|---|---|---|
| $force | bool | If true then it will create all static caches even if it is not outdated. |
| $quiet | bool | If true then the function will not output anything. |
| $cli | \eZCLI | false | The eZCLI object or false if no output can be done. |
| $delay | bool |

generateNodeListCache(
array $nodeList
)
:
voidGenerates caches for all the urls of nodes in $nodeList.
The associative array must have on of these entries: - node_id - ID of the node - path_identification_string - The path_identification_string from the node table, is used to fetch the node ID if node_id is missing.
| Name | Type | Description |
|---|---|---|
| $nodeList | array | An array with node entries, each entry is either the node ID or an associative array. |

hostName(
)
:
stringGetter method for {@link eZStaticCache::$hostName}
| Type | Description |
|---|---|
| string | The currently configured host-name. |
- Deprecated
- deprecated since version 4.4

maxCacheDepth(
)
:
intGetter method for {@link eZStaticCache::$maxCacheDepth}
| Type | Description |
|---|---|
| int | The maximum depth in the url which will be cached. |

removeURL(
string $url
)
:
voidRemoves the static cache file (index.html) and its directory if it exists.
The directory path is based upon the URL $url and the configured static storage dir.
| Name | Type | Description |
|---|---|---|
| $url | string | The URL for the current item, e.g /news |

storageDirectory(
)
:
stringGetter method for {@link eZStaticCache::$staticStorageDir}
| Type | Description |
|---|---|
| string | The currently configured storage directory for the static cache. |

storeCache(
string $url, string $staticStorageDir, array $alternativeStaticLocations
=
array(), bool $skipUnlink
=
false, bool $delay
=
true
)
:
voidStores the static cache for $url and hostname defined in site.ini.[SiteSettings].SiteURL for cached siteaccess by fetching the web page using {@link eZHTTPTool::getDataByURL()} and storing the fetched HTML data.
| Name | Type | Description |
|---|---|---|
| $url | string | The URL to cache, e.g /news |
| $staticStorageDir | string | The base directory for storing cache files. |
| $alternativeStaticLocations | array | |
| $skipUnlink | bool | If true it will not unlink existing cache files. |
| $delay | bool |