/** * @test */ public function flushRemovesAllCacheEntries() { $this->mockCacheFrontend->expects($this->any())->method('getIdentifier')->will($this->returnValue('UnitTestCache')); $entryIdentifier1 = 'SimpleFileBackendTest1'; $pathAndFilename1 = 'vfs://Temporary/Directory/Cache/Data/UnitTestCache/' . $entryIdentifier1; $entryIdentifier2 = 'SimpleFileBackendTest2'; $pathAndFilename2 = 'vfs://Temporary/Directory/Cache/Data/UnitTestCache/' . $entryIdentifier2; $simpleFileBackend = $this->getSimpleFileBackend(); $simpleFileBackend->set($entryIdentifier1, 'some data'); $simpleFileBackend->set($entryIdentifier2, 'some more data'); $this->assertFileExists($pathAndFilename1); $this->assertFileExists($pathAndFilename2); $this->assertTrue($simpleFileBackend->has($entryIdentifier1)); $this->assertTrue($simpleFileBackend->has($entryIdentifier2)); $simpleFileBackend->flush(); $this->assertFileNotExists($pathAndFilename1); $this->assertFalse($simpleFileBackend->has($entryIdentifier1)); $this->assertFileNotExists($pathAndFilename2); $this->assertFalse($simpleFileBackend->has($entryIdentifier2)); }
/** * Registers a cache so it can be retrieved at a later point. * * @param \TYPO3\Flow\Cache\Frontend\FrontendInterface $cache The cache frontend to be registered * @return void * @throws \TYPO3\Flow\Cache\Exception\DuplicateIdentifierException if a cache with the given identifier has already been registered. * @api */ public function registerCache(\TYPO3\Flow\Cache\Frontend\FrontendInterface $cache, $persistent = FALSE) { $identifier = $cache->getIdentifier(); if (isset($this->caches[$identifier])) { throw new \TYPO3\Flow\Cache\Exception\DuplicateIdentifierException('A cache with identifier "' . $identifier . '" has already been registered.', 1203698223); } $this->caches[$identifier] = $cache; if ($persistent === TRUE) { $this->persistentCaches[$identifier] = $cache; } }
/** * Deletes a cache entry. * * @param string $id The cache id. * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. */ public function delete($id) { return $this->cache->remove($this->convertCacheIdentifier($id)); }
/** * Deletes a cache entry. * * @param string $id The cache id. * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. */ public function delete($id) { return $this->cache->remove(md5($id)); }
/** * Returns the data of the current cache entry pointed to by the cache entry * iterator. * * @return mixed * @api */ public function current() { return $this->frontend->get($this->backend->key()); }
/** * Sets a reference to the cache frontend which uses this backend * * @param \TYPO3\Flow\Cache\Frontend\FrontendInterface $cache The frontend for this backend * @return void * @api */ public function setCache(\TYPO3\Flow\Cache\Frontend\FrontendInterface $cache) { $this->cache = $cache; $this->cacheIdentifier = $this->cache->getIdentifier(); }
/** * Sets a reference to the cache frontend which uses this backend * * @param FrontendInterface $cache The frontend for this backend * @return void * @api */ public function setCache(FrontendInterface $cache) { $this->cache = $cache; $this->cacheIdentifier = $this->cache->getIdentifier(); }
/** * Registers a cache so it can be retrieved at a later point. * * @param FrontendInterface $cache The cache frontend to be registered * @return void * @throws DuplicateIdentifierException if a cache with the given identifier has already been registered. * @api */ public function registerCache(FrontendInterface $cache, $persistent = false) { $identifier = $cache->getIdentifier(); if (isset($this->caches[$identifier])) { throw new DuplicateIdentifierException('A cache with identifier "' . $identifier . '" has already been registered.', 1203698223); } $this->caches[$identifier] = $cache; if ($persistent === true) { $this->persistentCaches[$identifier] = $cache; } }
/** */ protected function clearKlosterCache() { if ($this->cacheInterface->has('kloster')) { $this->cacheInterface->remove('kloster'); } }