/** * @return string The current cache version identifier */ public function render() { $version = $this->configurationCache->get('ConfigurationVersion'); if ($version === false) { $version = time(); $this->configurationCache->set('ConfigurationVersion', (string) $version); } return $version; }
/** * Tries to retrieve the specified content segment from the cache – further nested inline segments are retrieved * as well and segments which were not cacheable are rendered. * * @param \Closure $uncachedCommandCallback A callback to process commands in uncached segments * @param string $typoScriptPath TypoScript path identifying the TypoScript object to retrieve from the content cache * @param array $cacheIdentifierValues Further values which play into the cache identifier hash, must be the same as the ones specified while the cache entry was written * @param boolean $addCacheSegmentMarkersToPlaceholders If cache segment markers should be added – this makes sense if the cached segment is about to be included in a not-yet-cached segment * @return string|boolean The segment with replaced cache placeholders, or FALSE if a segment was missing in the cache * @throws Exception */ public function getCachedSegment($uncachedCommandCallback, $typoScriptPath, $cacheIdentifierValues, $addCacheSegmentMarkersToPlaceholders = false) { $cacheIdentifier = $this->renderContentCacheEntryIdentifier($typoScriptPath, $cacheIdentifierValues); $content = $this->cache->get($cacheIdentifier); if ($content === false) { return false; } $i = 0; do { $replaced = $this->replaceCachePlaceholders($content, $addCacheSegmentMarkersToPlaceholders); if ($replaced === false) { return false; } if ($i > self::MAXIMUM_NESTING_LEVEL) { throw new Exception('Maximum cache segment level reached', 1391873620); } $i++; } while ($replaced > 0); $this->replaceUncachedPlaceholders($uncachedCommandCallback, $content); if ($addCacheSegmentMarkersToPlaceholders) { return self::CACHE_SEGMENT_START_TOKEN . $this->randomCacheMarker . $cacheIdentifier . self::CACHE_SEGMENT_SEPARATOR_TOKEN . $this->randomCacheMarker . '*' . self::CACHE_SEGMENT_SEPARATOR_TOKEN . $this->randomCacheMarker . $content . self::CACHE_SEGMENT_END_TOKEN . $this->randomCacheMarker; } else { return $content; } }
/** * @test */ public function getFetchesStringValueFromBackend() { $backend = $this->prepareDefaultBackend(); $backend->expects($this->once())->method('get')->will($this->returnValue('Just some value')); $cache = new StringFrontend('StringFrontend', $backend); $this->assertEquals('Just some value', $cache->get('StringCacheTest'), 'The returned value was not the expected string.'); }
/** * Checks the cache for the given route values and returns the cached resolvedUriPath if a cache entry is found * * @param array $routeValues * @return string|boolean the cached request path or FALSE if no cache entry was found */ public function getCachedResolvedUriPath(array $routeValues) { $routeValues = $this->convertObjectsToHashes($routeValues); if ($routeValues === null) { return false; } return $this->resolveCache->get($this->buildResolveCacheIdentifier($routeValues)); }
/** * Loads the last detected files for this monitor. * * @return void */ protected function loadDetectedDirectoriesAndFiles() { if ($this->directoriesAndFiles === null) { $this->directoriesAndFiles = json_decode($this->cache->get($this->identifier . '_directoriesAndFiles'), true); if (!is_array($this->directoriesAndFiles)) { $this->directoriesAndFiles = []; } } }
/** * Returns the encryption key from the persistent cache or Data/Persistent directory. If none exists, a new * encryption key will be generated and stored in the cache. * * @return string The configured encryption key stored in Data/Persistent/EncryptionKey */ protected function getEncryptionKey() { if ($this->encryptionKey === null) { $this->encryptionKey = $this->cache->get('encryptionKey'); } if ($this->encryptionKey === false && file_exists(FLOW_PATH_DATA . 'Persistent/EncryptionKey')) { $this->encryptionKey = file_get_contents(FLOW_PATH_DATA . 'Persistent/EncryptionKey'); } if ($this->encryptionKey === false) { $this->encryptionKey = bin2hex(Utility\Algorithms::generateRandomBytes(48)); $this->cache->set('encryptionKey', $this->encryptionKey); } return $this->encryptionKey; }
/** * Loads all node types into memory. * * @return void */ protected function loadNodeTypes() { $this->fullNodeTypeConfigurations = $this->fullConfigurationCache->get('fullNodeTypeConfigurations'); $fillFullConfigurationCache = !is_array($this->fullNodeTypeConfigurations); $completeNodeTypeConfiguration = $this->configurationManager->getConfiguration('NodeTypes'); foreach (array_keys($completeNodeTypeConfiguration) as $nodeTypeName) { if (!is_array($completeNodeTypeConfiguration[$nodeTypeName])) { continue; } $nodeType = $this->loadNodeType($nodeTypeName, $completeNodeTypeConfiguration, isset($this->fullNodeTypeConfigurations[$nodeTypeName]) ? $this->fullNodeTypeConfigurations[$nodeTypeName] : null); if ($fillFullConfigurationCache) { $this->fullNodeTypeConfigurations[$nodeTypeName] = $nodeType->getFullConfiguration(); } } if ($fillFullConfigurationCache) { $this->fullConfigurationCache->set('fullNodeTypeConfigurations', $this->fullNodeTypeConfigurations); } $this->fullNodeTypeConfigurations = null; }
/** * Logs a user in if a session identifier is available under the given token in the token cache. * * @param string $token * @return void */ public function tokenLoginAction($token) { $newSessionId = $this->loginTokenCache->get($token); $this->loginTokenCache->remove($token); if ($newSessionId === false) { $this->systemLogger->log(sprintf('Token-based login failed, non-existing or expired token %s', $token), LOG_WARNING); $this->redirect('index'); } $this->systemLogger->log(sprintf('Token-based login succeeded, token %s', $token), LOG_DEBUG); $newSession = $this->sessionManager->getSession($newSessionId); if ($newSession->canBeResumed()) { $newSession->resume(); } if ($newSession->isStarted()) { $newSession->putData('lastVisitedNode', null); } else { $this->systemLogger->log(sprintf('Failed resuming or starting session %s which was referred to in the login token %s.', $newSessionId, $token), LOG_ERR); } $this->replaceSessionCookie($newSessionId); $this->redirect('index', 'Backend\\Backend'); }
/** * Initializes this strategy * * @param FileMonitor $fileMonitor * @return void */ public function setFileMonitor(FileMonitor $fileMonitor) { $this->fileMonitor = $fileMonitor; $this->filesAndModificationTimes = json_decode($this->cache->get($this->fileMonitor->getIdentifier() . '_filesAndModificationTimes'), true); }