/** * Initializes the caching. * Should be called before the first time anything is added via addCachedHTML. * * @since 1.20 * * @param integer|null $cacheExpiry Sets the cache expiry, either ttl in seconds or unix timestamp. * @param boolean|null $cacheEnabled Sets if the cache should be enabled or not. */ public function startCache($cacheExpiry = null, $cacheEnabled = null) { $this->cacheHelper = new CacheHelper(); $this->cacheHelper->setCacheEnabled($this->cacheEnabled); $this->cacheHelper->setOnInitializedHandler(array($this, 'onCacheInitialized')); $keyArgs = $this->getCacheKey(); if (array_key_exists('action', $keyArgs) && $keyArgs['action'] === 'purge') { unset($keyArgs['action']); } $this->cacheHelper->setCacheKey($keyArgs); if ($this->getRequest()->getText('action') === 'purge') { $this->cacheHelper->rebuildOnDemand(); } $this->cacheHelper->startCache($cacheExpiry, $cacheEnabled); }