/** * Caches the response * @param \ride\web\WebApplication $web * @return null */ public function cacheResponse(WebApplication $web) { if (!isset($this->cache)) { return; } if (!isset($this->cacheTtl)) { $this->cacheTtl = 0; } $request = $web->getRequest(); $response = $web->getResponse(); $cacheKey = 'node.response.' . StringHelper::safeString($request->getUrl()); if ($this->log) { $this->log->logDebug('Caching the request', 'Ttl: ' . $this->cacheTtl . ' - ' . $cacheKey, ApplicationListener::LOG_SOURCE); } $cachedResponse = $this->cache->create($cacheKey); $cachedResponse->setValue($response); $cachedResponse->setTtl($this->cacheTtl); $this->cache->set($cachedResponse); }