2013-04-10 70 views
1

在TYPO3中,我想用一些GET值从缓存表中删除单个页面。我还没有找到一个扩展,它将处理这个或TYPO3方法。TYPO3:计算缓存标识符散列值?

  1. 是否有一个函数,我可以交出一个URL或类似的,产生缓存哈希标识符或从缓存表中删除特定的数据?
  2. 如果没有,是否有人知道,该算法是什么,计算哈希标识符或我可能找到哪个文件?

所以,任何帮助将不胜感激。

我TYPO3版本:4.5.x

回答

0

是这样的:

你需要一个适当的TSFE对象$GLOBALS['TSFE']
那么你需要从localconf $TYPO3_CONF_VARS['SYS']['encryptionKey'] 和URL参数,例如加密密钥`tx_ttnews [tt_news]

然后这些步骤

  1. 创建与加密密钥的(排序的)阵列和URL参数
  2. 手移到该阵列到TSFE对象的属性cHash_array
  3. 从TSFE的getHash方法获取cHash值

$arr = array(
    'encryptionKey' => $TYPO3_CONF_VARS['SYS']['encryptionKey'], 
    'tx_ttnews[tt_news]' => $newsid, 
    // ... 
) 
ksort($array); 
$GLOBALS['TSFE']->cHash_array = $array; 
$chash = $GLOBALS['TSFE']->getHash(); 
0

您可以创建一个清除指定页面的缓存功能,则需要以下代码:

TYPO3 6.0

public function clearCache($cacheCmd) { 
    /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */ 
    $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("TYPO3\\CMS\\Core\\DataHandling\\DataHandler"); 
    $tce->stripslashes_values = 0; 
    $tce->start(array(), array()); 

    switch($cacheCmd) { 
     case 'pages': 
     case 'all': 
      $tce->admin = 1; 
    } 

    $tce->clear_cacheCmd($cacheCmd); 
    unset($tce); 
} 

TYPO3 4 .x

public function clearCache($cacheCmd) { 
    /** @var $tce t3lib_TCEmain */ 
    $tce = t3lib_div::makeInstance("t3lib_TCEmain"); 
    $tce->stripslashes_values = 0; 
    $tce->start(array(), array()); 

    switch($cacheCmd) { 
     case 'pages': 
     case 'all': 
      $tce->admin = 1; 
    } 

    $tce->clear_cacheCmd($cacheCmd); 
    unset($tce); 
} 

$cacheCmd可以有以下值: /typo3/sysext/core/Classes/DataHandling/DataHandler.php:clear_cacheCmd(> 6.0)或/t3lib/class.t3lib_tcemain.php(4.x版)

/** 
* Clears the cache based on the command $cacheCmd. 
* 
* $cacheCmd='pages': Clears cache for all pages. Requires admin-flag to 
* be set for BE_USER. 
* 
* $cacheCmd='all':  Clears all cache_tables. This is necessary if 
* templates are updated. Requires admin-flag to be set for BE_USER. 
* 
* $cacheCmd=[integer]: Clears cache for the page pointed to by $cacheCmd 
* (an integer). 
* 
* $cacheCmd='cacheTag:[string]': Flush page and pagesection cache by given tag 
* 
* $cacheCmd='cacheId:[string]': Removes cache identifier from page and page section cache 
* 
* Can call a list of post processing functions as defined in 
* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'] 
* (numeric array with values being the function references, called by 
* \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction()). 
* 
* Note: The following cache_* are intentionally not cleared by 
* $cacheCmd='all': 
* 
* - cache_md5params: RDCT redirects. 
* - cache_imagesizes: Clearing this table would cause a lot of unneeded 
* Imagemagick calls because the size informations have 
* to be fetched again after clearing. 
* 
* @param string $cacheCmd The cache command, see above description 
* @return void 
*/ 

调用此有userFunc如果给定的参数在Typo脚本设置或通过创建自己的简单延伸。

+0

哦,对不起。我没有给我的版本的TYPO3。我需要Typo3 4.5.x代码 – HerrSerker 2013-04-10 14:02:35

+0

我已经添加了v4代码 – Merec 2013-04-10 14:08:23

+0

Thx。但它不回答我的问题。我需要一种方法来计算cacheId。 – HerrSerker 2013-04-10 14:26:47