eZPublish  4.4
eZTemplateCacheBlock Class Reference

Cache block. More...

Static Public Member Functions

static cachePath ($keyString, $nodeID=false)
 
static calculateSubtreeCacheDir ($nodeID, $cacheFilename)
 
static decodeNodeID ($subtreeExpiryParameter)
 
static getSubtreeModification ($nodeID)
 
static handle ($cachePath, $nodeID, $ttl, $useGlobalExpiry=true)
 
static keyString ($keys)
 
static placementString ($functionPlacement)
 
static retrieve ($keys, $subtreeExpiry, $ttl, $useGlobalExpiry=true)
 
static retrieveContent ($fname, $mtime)
 
static subtreeCacheBaseSubDir ()
 
static subtreeCacheSubDir ($subtreeExpiryParameter, $cacheFilename)
 
static subtreeCacheSubDirForNode ($nodeID)
 
static templateBlockCacheDir ()
 

Detailed Description

Cache block.

Member Function Documentation

static eZTemplateCacheBlock::cachePath (   $keyString,
  $nodeID = false 
)
static

Calculates the cache path based on the key string $keyString and $nodeID.

See subtreeCacheSubDir() for more details on the $nodeID parameter.

Referenced by eZTemplateCacheFunction\processCached(), retrieve(), and eZTemplateCacheFunction\templateNodeTransformation().

static eZTemplateCacheBlock::calculateSubtreeCacheDir (   $nodeID,
  $cacheFilename 
)
static

Returns path of the directory where 'subtree_expiry' caches are stored.

See decodeNodeID() for details on the $subtreeExpiryParameter parameter.

Referenced by cachePath(), and subtreeCacheSubDir().

static eZTemplateCacheBlock::decodeNodeID (   $subtreeExpiryParameter)
static

Figures out the node ID for the $subtreeExpiryParameter.

The parameter $subtreeExpiryParameter is expiry value is usually taken from the template operator and can be one of:

  • A numerical value which represents the node ID (the fastest approach)
  • A string containing 'content/view/full/xxx' where xx is the node ID number, the number will be extracted.
  • A string containing a nice url which will be decoded into a node ID using the database (slowest approach).

Referenced by eZTemplateCacheFunction\processCached(), retrieve(), subtreeCacheSubDir(), and eZTemplateCacheFunction\templateNodeTransformation().

static eZTemplateCacheBlock::getSubtreeModification (   $nodeID)
static

Figures out the modification time for the subtree by looking up the database using $nodeID. If $nodeID is set to false no lookup is done and it will return -1.

Referenced by handle().

static eZTemplateCacheBlock::handle (   $cachePath,
  $nodeID,
  $ttl,
  $useGlobalExpiry = true 
)
static

Helper function for the compiled code, similar to retrieve() but requires the $cachePath to be calculated up front.

Referenced by retrieve().

static eZTemplateCacheBlock::keyString (   $keys)
static

Calculates the key string from the key values $keys.

Note: Arrays are traversed recursively.

Referenced by eZTemplateCacheFunction\processCached(), retrieve(), and eZTemplateCacheFunction\templateNodeTransformation().

static eZTemplateCacheBlock::placementString (   $functionPlacement)
static

Calculates the key entry for the function placement array $functionPlacement and returns it.

Note
This function is placed in this class to reduce the need to load the class eZTemplateCacheFunction when the templates are compiled. This reduces memory usage.

Referenced by eZTemplateCacheFunction\processCachedPreprocess(), and eZTemplateCacheFunction\templateNodeTransformation().

static eZTemplateCacheBlock::retrieve (   $keys,
  $subtreeExpiry,
  $ttl,
  $useGlobalExpiry = true 
)
static

Helper function for retrieving a cache-block entry which can be used by any custom code.

Parameters
$keysArray or string which is used for key. To ensure uniqueness prefix or add an entry which is unique to your code.
$subtreeExpiryThe subtree expiry value, use null to disable or a string. See subtreeCacheSubDir for more details.
$ttlAmount of seconds the cache should live, use null, 0 or -1 to disable TTL.
$useGlobalExpiryBoolean which controls if the global content expiry value should be used or not.

Returns an array with the file handler objects as the first entry and the content data as the second. If the content could not be retrieved the content contains the object eZClusterFileFailure.

Example of usage:

list($handler, $data) = eZTemplateCacheBlock::retrieve( array( 'my_cool_key', $id, ), $nodeID, 60 ); // lives 60 seconds
if ( !$data instanceof eZClusterFileFailure )
{
echo $data;
}
else
{
// ... generate the data
$data = '...';
$handler->storeCache( array( 'scope' => 'template-block',
'binarydata' => $data ) );
}

Note: Because of the cluster code the storeCache() call must occur to ensure stability.

static eZTemplateCacheBlock::retrieveContent (   $fname,
  $mtime 
)
static

Callback function to get the contents of the specified filename.

Parameters
$fnameName of file
$mtimeModified time of file.
static eZTemplateCacheBlock::subtreeCacheBaseSubDir ( )
static

Returns base directory where 'subtree_expiry' caches are stored.

Referenced by eZTemplateCacheFunction\subtreeCacheBaseSubDir(), and subtreeCacheSubDirForNode().

static eZTemplateCacheBlock::subtreeCacheSubDir (   $subtreeExpiryParameter,
  $cacheFilename 
)
static

Returns path of the directory where 'subtree_expiry' caches are stored.

See decodeNodeID() for details on the $subtreeExpiryParameter parameter.

Note
If you know the node ID you can use calculateSubtreeCacheDir() instead.

Referenced by eZTemplateCacheFunction\subtreeCacheSubDir().

static eZTemplateCacheBlock::subtreeCacheSubDirForNode (   $nodeID)
static

Builds and returns path from $nodeID, e.g. if $nodeID = 23 then path = subtree/2/3

Referenced by calculateSubtreeCacheDir(), and eZTemplateCacheFunction\subtreeCacheSubDirForNode().

static eZTemplateCacheBlock::templateBlockCacheDir ( )
static

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