/**
  * Clears a specific template
  */
 public function clearTemplate()
 {
     if ($this->request->param('ID')) {
         $this->cache->flushByName($this->request->param('ID'));
         return 'Done' . PHP_EOL;
     } else {
         return 'You must specify a template:' . PHP_EOL . $this->index();
     }
 }
 /**
  * Invalidates a cache by a certain name, and logs if available
  * @param $name
  * @param $message
  * @param null $logger
  */
 protected function invalidate($name, $message, $logger = null)
 {
     $this->cache->flushByName($name);
     if ($logger) {
         $logger->info($message);
     }
 }
 /**
  * If this request allows caching then cache it
  * @param  SS_HTTPRequest  $request
  * @param  SS_HTTPResponse $response
  * @param  DataModel       $model
  * @return bool
  */
 public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
 {
     if ($response instanceof SS_HTTPResponse && $this->allowSave($request, $response)) {
         $response = clone $response;
         if ($this->hasTokens()) {
             $body = $response->getBody();
             foreach ($this->tokens as $token) {
                 $val = $token->getValue();
                 if (strpos($body, $val) !== false) {
                     $body = str_replace($val, self::REPLACED_TOKEN_PREFIX . $token->getName(), $body);
                 }
             }
             $response->setBody($body);
         }
         if (Director::is_ajax()) {
             Requirements::include_in_response($response);
         }
         $this->cache->set($this->name, $response, \Injector::inst()->create('CacheIncludeKeyCreator', $this->getController($request)));
     }
     return true;
 }
 public function testForceExpire()
 {
     $this->cacheinclude->setForceExpire(true);
     $this->assertTrue($this->cacheinclude->getForceExpire());
 }