0

我想知道如何为我自己的扩展配置 coorectly 缓存。

到目前为止,我做了以下事情:

ext_localconf.php

if (!is_array($TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][$_EXTKEY])) {
  $TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][$_EXTKEY] = array();
  $TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][$_EXTKEY]['frontend'] = 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend';
  $TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][$_EXTKEY]['backend'] = 'TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend';
  $TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][$_EXTKEY]['options']['compression'] = 1;
}

在我的 TestController.php 我写了这个:

$this->cache = $GLOBALS['typo3CacheManager']->getCache(
            $this->request->getControllerExtensionKey()
);

$cacheIdentifier = sha1('form_data_' . $GLOBALS["TSFE"]->id);

$formData = array();


if ($this->cache->has($cacheIdentifier)) { //This always results to false
  $formData = $this->cache->get($cacheIdentifier);
} else {
  $conditions = array(
     path' => $this->settings['httpClient']['baseUrl'] . 'list.xml'
  );

  $formData = $this->TestRepository->getFormData($conditions);
  $this->cache->set($cacheIdentifier,$formData);
}

所以我不知道我做错了什么。

有人可以指出我正确的方向。

我正在使用 TYPO3 6.1.5 extbase 6.1.0

4

1 回答 1

1

好的,当我检查 TYPO3_CONF_VARS 的 FLUID 模板时,我找到了答案:

他们有一些不同的缓存配置:

将 ext_localconf.php 更改为

$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][$_EXTKEY]['frontend'] =
'TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend';
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][$_EXTKEY]['backend'] =
'TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend';

一切正常。

于 2013-10-12T15:36:04.007 回答