eZ Publish  [trunk]
eZTemplateCacheBlock Class Reference

Cache block. More...

List of all members.

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.

Definition at line 17 of file eztemplatecacheblock.php.


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.

Definition at line 142 of file eztemplatecacheblock.php.

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.

Definition at line 234 of file eztemplatecacheblock.php.

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

Definition at line 179 of file eztemplatecacheblock.php.

Referenced by retrieve(), and subtreeCacheSubDir().

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.

Definition at line 95 of file eztemplatecacheblock.php.

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.

Definition at line 61 of file eztemplatecacheblock.php.

Referenced by retrieve().

static eZTemplateCacheBlock::keyString ( keys) [static]

Calculates the key string from the key values $keys.

Note: Arrays are traversed recursively.

Definition at line 131 of file eztemplatecacheblock.php.

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.

Definition at line 115 of file eztemplatecacheblock.php.

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.

Definition at line 50 of file eztemplatecacheblock.php.

static eZTemplateCacheBlock::retrieveContent ( fname,
mtime 
) [static]

Callback function to get the contents of the specified filename.

Parameters:
$fnameName of file
$mtimeModified time of file.

Definition at line 300 of file eztemplatecacheblock.php.

Returns base directory where 'subtree_expiry' caches are stored.

Definition at line 288 of file eztemplatecacheblock.php.

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

Definition at line 250 of file eztemplatecacheblock.php.

static eZTemplateCacheBlock::subtreeCacheSubDirForNode ( nodeID) [static]

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

Definition at line 260 of file eztemplatecacheblock.php.

Referenced by calculateSubtreeCacheDir().


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