Friday 11 September 2009 12:49:30 am
Thx for your reply André! We are using the keys and the subtree_expiry in the template:
{cache-block keys = array($current_node_id, $module_result.uri, $user_hash) subtree_expiry = $super_menu_root_node_id}
We are calling the cachePath function <b>outside</b> eZ Publish but with the subtree_expiry we still need to generate that enormous long key string to fetch it from the file-system right? We know the $current_node_id, $module_result.uri and the $user_hash outside eZ Publish and we also know the $super_menu_root_node_id. But we can not generate the key without all the other info. the code we're using for generating cache-block path:
class eZBlock {
static function cachePath($keyString, $nodeID = false){
//include_once( 'ezsys.php' );
$checksum = sprintf('%u', crc32(serialize($keyString)));
$filename = $checksum.'.cache';
$phpDir = ezBlock::templateBlockCacheDir();
if(is_numeric($nodeID)) {
$phpDir .= ezBlock::calculateSubtreeCacheDir($nodeID, $filename);
} else {
$phpDir .= $filename[0].'/'.$filename[1].'/'.$filename[2];
}
$phpPath = $phpDir.'/'.$filename;
return $phpPath;
}
static function templateBlockCacheDir() {
$cacheDir = '.../var/cmandev_com/cache/template-block/';
return $cacheDir;
}
static function calculateSubtreeCacheDir($nodeID, $cacheFilename) {
$cacheDir = ezBlock::subtreeCacheSubDirForNode($nodeID);
$cacheDir .='/'.$cacheFilename[0].'/'.$cacheFilename[1].'/'.$cacheFilename[2];
return $cacheDir;
}
static function subtreeCacheBaseSubDir() {
return 'subtree';
}
static function subtreeCacheSubDirForNode($nodeID) {
$cacheDir = ezBlock::subtreeCacheBaseSubDir();
if (is_numeric($nodeID)) {
$nodeID = (string)$nodeID;
$length = strlen($nodeID);
$pos = 0;
while ($pos<$length) {
$cacheDir .= '/'.$nodeID[$pos];
++$pos;
}
} else {
}
$cacheDir .= '/cache';
return $cacheDir;
}
}
echo eZBlock::cachePath(array(60, '/', '1,'), 62).'<br />';
echo eZBlock::cachePath(array(60, '/', '1,'), 63).'<br />';
The result of this code can be found on: http://www.mybiz.cc/webshop/load_ez_header3.php
|