public function postRequest(\SS_HTTPRequest $request, \SS_HTTPResponse $response, \DataModel $model) { if ($request->getVar('clear') && Member::currentUserID() && Permission::check('ADMIN')) { $key = trim($request->getVar('url'), '/'); $key = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . '/' . $key; $item = $this->dynamicCache->get($key); if ($item) { $response->addHeader('X-SilverStripe-Cache', 'deleted ' . $key); $this->dynamicCache->delete($key); } } }
public function forTemplate() { $key = $this->getKey(); $cache = $this->getCache(); $data = $cache->get($key); if ($data && !$this->forceRegen) { if (defined('PROXY_CACHE_GENERATING')) { return '<!--SimpleCache::' . $key . ',FragmentCache-->'; } return $data; } $data = $this->context->renderWith($this->templateName); $data = $data->raw(); if (Versioned::current_stage() != 'Stage' && strlen($data) && !isset($_GET['flush'])) { // $this->cache->store($key, $menu, self::CACHE_LENGTH); // when storing for the frontend cache replacement stuff, use whatever we have // configured // do NOT store if we're on stage or we have _flush=1 $this->cache->store($key, $data); } // clear the cache key for next request if (isset($_GET['flush'])) { $this->cache->delete($key); } if (defined('PROXY_CACHE_GENERATING')) { return '<!--SimpleCache::' . $key . ',FragmentCache-->'; } return $data; }