Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Static Public Member Functions | Static Private Member Functions | List of all members
eZTemplateCacheBlock Class Reference

Cache block. More...

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

## Static Private Member Functions
static | filterKeys (array &$keys)

## Detailed Description

Cache block.

Definition at line 17 of file eztemplatecacheblock.php.

## Member Function Documentation

## ◆ cachePath()

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 168 of file eztemplatecacheblock.php.

References calculateSubtreeCacheDir(), and templateBlockCacheDir().

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

## ◆ calculateSubtreeCacheDir()

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 260 of file eztemplatecacheblock.php.

References subtreeCacheSubDirForNode().

Referenced by cachePath(), and subtreeCacheSubDir().

## ◆ decodeNodeID()

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 205 of file eztemplatecacheblock.php.

References eZURLAliasML\fetchNodeIDByPath(), and eZDebug\writeError().

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

## ◆ filterKeys()

static eZTemplateCacheBlock::filterKeys | ( | array & | $keys | ) |
| static private

Filters cache keys when needed. Useful to avoid having current URI as a cache key if an error has occurred and has been caught by error module.

Parameters

  array | $keys |

Definition at line 65 of file eztemplatecacheblock.php.

References eZSys\requestURI().

Referenced by retrieve().

## ◆ getSubtreeModification()

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 121 of file eztemplatecacheblock.php.

References eZDB\instance().

Referenced by handle().

## ◆ 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 88 of file eztemplatecacheblock.php.

References getSubtreeModification(), and eZClusterFileHandler\instance().

Referenced by retrieve().

## ◆ keyString()

static eZTemplateCacheBlock::keyString | ( |  | $keys | ) |
| static

Calculates the key string from the key values $keys.

Note: Arrays are traversed recursively.

Definition at line 157 of file eztemplatecacheblock.php.

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

## ◆ placementString()

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 141 of file eztemplatecacheblock.php.

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

## ◆ retrieve()

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

  $keys | Array or string which is used for key. To ensure uniqueness prefix or add an entry which is unique to your code.
  $subtreeExpiry | The subtree expiry value, use null to disable or a string. See subtreeCacheSubDir for more details.
  $ttl | Amount of seconds the cache should live, use null, 0 or -1 to disable TTL.
  $useGlobalExpiry | Boolean 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 ) );
}
eZClusterFileFailure
Definition: ezclusterfilefailure.php:20
eZTemplateCacheBlock\retrieve
static retrieve( $keys, $subtreeExpiry, $ttl, $useGlobalExpiry=true)
Definition: eztemplatecacheblock.php:50

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

Definition at line 50 of file eztemplatecacheblock.php.

References cachePath(), decodeNodeID(), filterKeys(), handle(), and keyString().

## ◆ retrieveContent()

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

Callback function to get the contents of the specified filename.

Parameters

  $fname | Name of file
  $mtime | Modified time of file.

Definition at line 326 of file eztemplatecacheblock.php.

## ◆ subtreeCacheBaseSubDir()

static eZTemplateCacheBlock::subtreeCacheBaseSubDir | ( |  | ) |
| static

Returns base directory where 'subtree_expiry' caches are stored.

Definition at line 314 of file eztemplatecacheblock.php.

Referenced by eZSubtreeCache\cleanupAll(), and subtreeCacheSubDirForNode().

## ◆ subtreeCacheSubDir()

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 276 of file eztemplatecacheblock.php.

References calculateSubtreeCacheDir(), and decodeNodeID().

## ◆ subtreeCacheSubDirForNode()

static eZTemplateCacheBlock::subtreeCacheSubDirForNode | ( |  | $nodeID | ) |
| static

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

Definition at line 286 of file eztemplatecacheblock.php.

References subtreeCacheBaseSubDir(), and eZDebug\writeWarning().

Referenced by calculateSubtreeCacheDir(), and eZSubtreeCache\cleanup().

## ◆ templateBlockCacheDir()

static eZTemplateCacheBlock::templateBlockCacheDir | ( |  | ) |
| static

Returns base directory where template block caches are stored.

Definition at line 190 of file eztemplatecacheblock.php.

References eZSys\cacheDirectory().

Referenced by cachePath(), eZSubtreeCache\cleanup(), and eZSubtreeCache\cleanupAll().

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

- eztemplatecacheblock.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.