eZ Community » Learn » eZ Publish » eZ Publish Cache In Details:...

eZ Publish Cache In Details: expiry.php and ezcache.php command

Wednesday 05 June 2013 2:46:43 pm

  • Currently 3 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

The ezcache.php script

This table summarizes the list of available parameters for the ezcache.php script and their impact on the system. We must distinguish 3 types of parameters :

  • --clear-all : this parameter targets every kind of cache
  • --clear-tag : this parameter a set of caches (ID list), thematically groupes in the same tag
  • --clear-id : this parameter targets a single type of cache

You can add other parameters when calling the script

  • --purge : concernés requires a purge of the files, with a more or less real impact depending on the ID. The table below describes the impact of the --purge directive for each of these IDs
  • --expiry : allows to define an expiry date to be consider, ‘now’, ‘-2 days’, ‘last monday’, only for ID-related functions
  • --s --siteaccess : Used to force the use of a site_access to use the relevant settings, if not given the default site_access is used
  • --iteration-sleep : not tested
  • --iteration-max : not tested

Other parameters are dedicated to assistance :

  • --help : displays help with the list of parameters and their meanings (less detailled than in the document)
  • --list-ids : displays the list of usable IDs
  • --list-tags : displays the list of usable TAGs

When calling a cache expiry by the ezcache.php command, the PHP array of the kernel/classes/ezcache.php class is used to define what type of action to run.

array( 'name' => ezpI18n::tr( 'kernel/cache', 'Text to image cache' ),
  'id' => 'texttoimage',
  'tag' => array( 'template' ),
  'enabled' => $textToImageIni->variable( 'ImageSettings', 'UseCache' ) == 'enabled',
  'path' => $textToImageIni->variable( 'PathSettings', 'CacheDir' ),
  'function' => array( 'eZCache', 'clearTextToImageCache' ),
  'purge-function' => array( 'eZCache', 'purgeTextToImageCache' ),
  'is-clustered' => true )

 

These parameters are used to define the type of action to take. Here is an excerpt of the relevant PHP code ( kernel/classes/ezcache.php ), which is relatively understandable by reading his algorithm:

 

// Recovering any function
// - If --purge and 'purge-function' exists
// - Or if --purge and 'function' doesn’t exists
if ( $purge && isset( $cacheItem['purge-function'] ) )
 $functionName = 'purge-function';
else if ( !$purge && isset( $cacheItem['function'] ) )
  $functionName = 'function';
 
 // Then, if a function exists
if ( $functionName )
{
 // ... executes the function declared in ‘function’
 call_user_func_array( $function, array( $cacheItem ) );
}
else
{
 // If ‘is-clustered’ is true, we force the recursive removal in cluster mode
 // touch, update SQL... depending on the filehandler defined in file.ini
  if ( $isClustered )
 {
 $fileHandler = eZClusterFileHandler::instance( $cachePath );
 if ( $purge ) $fileHandler->purge( $reporter, $iterationSleep, $iterationMax, $expiry );
 else
 $fileHandler->delete();
  return;
 }
 // ... Recursively removes (unlink) the path defined in 'path'
 eZDir::recursiveDelete( $cachePath );
}

Many bugs appeared in version eZ 4.x until version 4.5 (the informations of the table below are for eZ Publish 2012.x) that do not systematically defined value for ‘function-purge’. This lack os definition caused an unpredictable effect when using --purge, ie no action (Reading again the algorithm allows us to understand that if --purge is invoked and that only the ‘function’ parameter is present, then no specific PHP function is called).

 

 

 
36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)

Proudly Developed with from