【问题标题】:How to configure Caching in own Extension如何在自己的扩展中配置缓存
【发布时间】:2013-10-12 15:26:51
【问题描述】:

我想知道如何为我自己的扩展配置 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 扩展库 6.1.0

【问题讨论】:

    标签: typo3 extbase


    【解决方案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';
    

    一切正常。

    【讨论】:

    • 如果有时间,您能否解释一下为什么“默认”的前端和后端缓存概念不起作用?
    • 是的,我可以。我已经排除了由于不同原因缓存的动作表单。我对从“Hand”缓存的 REST 服务有类似的请求
    • 我真正想知道的是出于什么原因我需要将默认前端缓存替换为其他一些例如?
    猜你喜欢
    • 2014-10-09
    • 2020-09-05
    • 1970-01-01
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多