eZ Publish  [4.2]
eZStaticCache Class Reference

Manages the static cache system. More...

List of all members.

Public Member Functions

 alwaysUpdateURLArray ()
 cachedSiteAccesses ()
 cachedURLArray ()
 eZStaticCache ()
 generateAlwaysUpdatedCache ($quiet=false, $cli=false, $delay=true)
 generateCache ($force=false, $quiet=false, $cli=false, $delay=true)
 generateNodeListCache ($nodeList)
 hostName ()
 maxCacheDepth ()
 removeURL ($url)
 storageDirectory ()

Static Public Member Functions

static executeActions ()

Public Attributes

 $AlwaysUpdate
 An array with URLs that is to always be updated.
 $CachedURLArray
 Array of URLs to cache.
 $HostName
 The name of the host to fetch HTML data from.
 $MaxCacheDepth
 The maximum depth of URLs that will be cached.
 $StaticStorage
 The base path for the directory where static files are placed.
const USER_AGENT = 'eZ Publish static cache generator'

Private Member Functions

 addAction ($action, $parameters)
 buildCacheFilename ($staticStorageDir, $url)
 cacheURL ($url, $nodeID=false, $skipExisting=false, $delay=true)
 storeCache ($url, $hostname, $staticStorageDir, $alternativeStaticLocations=array(), $skipUnlink=false, $delay=true)

Static Private Member Functions

static storeCachedFile ($file, $content)

Detailed Description

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 instatiating the class and then calling generateCache(). For example:

  $staticCache = new eZStaticCache();
  $staticCache->generateCache();

To generate the URLs that must always be updated call generateAlwaysUpdatedCache()

Definition at line 52 of file ezstaticcache.php.


Member Function Documentation

eZStaticCache::addAction ( action,
parameters 
) [private]

This function adds an action to the list that is used at the end of the request to remove and regenerate static cache files.

Definition at line 451 of file ezstaticcache.php.

Referenced by storeCache().

eZStaticCache::alwaysUpdateURLArray ( )
Returns:
An array with URLs that is to always be updated.
Note:
These URLs are configured with AlwaysUpdateArray in staticcache.ini.
See also:
generateAlwaysUpdatedCache()

Definition at line 115 of file ezstaticcache.php.

eZStaticCache::buildCacheFilename ( staticStorageDir,
url 
) [private]
Parameters:
$staticStorageDirThe storage for cache files.
$urlThe URL for the current item, e.g /news
Returns:
The full path to the cache file (index.html) based on the input parameters.

Definition at line 390 of file ezstaticcache.php.

Referenced by storeCache().

eZStaticCache::cachedSiteAccesses ( )
Returns:
An array with site-access names that should be cached.

Definition at line 97 of file ezstaticcache.php.

eZStaticCache::cachedURLArray ( )
Returns:
An array with URLs that is to be cached statically, the URLs may contain wildcards.

Definition at line 105 of file ezstaticcache.php.

Referenced by generateCache().

eZStaticCache::cacheURL ( url,
nodeID = false,
skipExisting = false,
delay = true 
) [private]

Generates the caches for the url $url using the currently configured hostName() and storageDirectory().

Parameters:
$urlThe URL to cache, e.g /news
$nodeIDThe ID of the node to cache, if supplied it will also cache content/view/full/xxx.
$skipExistingIf true it will not unlink existing cache files.

Definition at line 276 of file ezstaticcache.php.

Referenced by generateCache(), and generateNodeListCache().

static eZStaticCache::executeActions ( ) [static]

This function goes over the list of recorded actions and excecutes them.

Definition at line 463 of file ezstaticcache.php.

eZStaticCache::eZStaticCache ( )

Initialises the static cache object with settings from staticcache.ini.

Definition at line 59 of file ezstaticcache.php.

eZStaticCache::generateAlwaysUpdatedCache ( quiet = false,
cli = false,
delay = true 
)

Generates the caches for all URLs that must always be generated.

See also:
alwaysUpdateURLArray().

Definition at line 125 of file ezstaticcache.php.

eZStaticCache::generateCache ( force = false,
quiet = false,
cli = false,
delay = true 
)

Generates the static cache from the configured INI settings.

Parameters:
$forceIf true then it will create all static caches even if it is not outdated.
$quietIf true then the function will not output anything.
$cliThe eZCLI object or false if no output can be done.

Definition at line 186 of file ezstaticcache.php.

eZStaticCache::generateNodeListCache ( nodeList)

Generates caches for all the urls of nodes in $nodeList. $nodeList is an array with node entries, each entry is either the node ID or an associative array. 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.

Definition at line 147 of file ezstaticcache.php.

eZStaticCache::hostName ( )
Returns:
The currently configured host-name.

Definition at line 73 of file ezstaticcache.php.

eZStaticCache::maxCacheDepth ( )
Returns:
The maximum depth in the url which will be cached.

Definition at line 89 of file ezstaticcache.php.

eZStaticCache::removeURL ( url)

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

Parameters:
$urlThe URL for the curren item, e.g /news

Definition at line 438 of file ezstaticcache.php.

eZStaticCache::storageDirectory ( )
Returns:
The currently configured storage directory for the static cache.

Definition at line 81 of file ezstaticcache.php.

eZStaticCache::storeCache ( url,
hostname,
staticStorageDir,
alternativeStaticLocations = array(),
skipUnlink = false,
delay = true 
) [private]

Stores the static cache for $url and $hostname by fetching the web page using fopen() and storing the fetched HTML data.

Parameters:
$urlThe URL to cache, e.g /news
$hostnameThe name of the host which serves web pages dynamically, see hostName().
$staticStorageDirThe base directory for storing cache files, see storageDirectory().
$alternativeStaticLocationsAn array with additional URLs that should also be cached.
$skipUnlinkIf true it will not unlink existing cache files.

Definition at line 325 of file ezstaticcache.php.

Referenced by cacheURL(), and generateAlwaysUpdatedCache().

static eZStaticCache::storeCachedFile ( file,
content 
) [static, private]

Stores the cache file $file with contents $content. Takes care of setting proper permissions on the new file.

Definition at line 403 of file ezstaticcache.php.

Referenced by storeCache().


Member Data Documentation

eZStaticCache::$AlwaysUpdate

An array with URLs that is to always be updated.

Definition at line 531 of file ezstaticcache.php.

eZStaticCache::$CachedURLArray

Array of URLs to cache.

Definition at line 529 of file ezstaticcache.php.

eZStaticCache::$HostName

The name of the host to fetch HTML data from.

Definition at line 523 of file ezstaticcache.php.

eZStaticCache::$MaxCacheDepth

The maximum depth of URLs that will be cached.

Definition at line 527 of file ezstaticcache.php.

eZStaticCache::$StaticStorage

The base path for the directory where static files are placed.

Definition at line 525 of file ezstaticcache.php.

const eZStaticCache::USER_AGENT = 'eZ Publish static cache generator'

Definition at line 54 of file ezstaticcache.php.

Referenced by storeCache().


The documentation for this class was generated from the following file: