MadeOfSport
MadeOfSport

Reputation: 513

How to configure Caching in own Extension

I'm wondering how to configure coorectly caching for my own extension.

So far i did the following:

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;
}

in my TestController.php i wrote this:

$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);
}

So i didn't know what i do wrong.

Can somebody point me to the right direction.

I'm working with TYPO3 6.1.5 extbase 6.1.0

Upvotes: 0

Views: 862

Answers (1)

MadeOfSport
MadeOfSport

Reputation: 513

Ok i found the answer as i checked TYPO3_CONF_VARS for FLUID Tamplates:

They had some different Cache Configurations:

After channging ext_localconf.php to

$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';

everything works fine.

Upvotes: 1

Related Questions