8000 [HttpCache] made purge deleting cache entries by bamarni · Pull Request #7361 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpCache] made purge deleting cache entries #7361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[HttpCache] made purge deleting cache entries
  • Loading branch information
bamarni committed Mar 13, 2013
commit a5c6f3a558d133889869268c0480594fb30b5561
14 changes: 10 additions & 4 deletions src/Symfony/Component/HttpKernel/HttpCache/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,19 @@ private function getMetadata($key)
*/
public function purge($url)
{
if (is_file($path = $this->getPath($this->getCacheKey(Request::create($url))))) {
unlink($path);
$key = $this->getCacheKey(Request::create($url));

return true;
$path = $this->getPath($key);
if (!is_file($path)) {
return false;
}

foreach ($this->getMetadata($key) as $entry) {
$response = $this->restoreResponse($entry[1]);
unlink($this->getPath($response->headers->get('X-Content-Digest')));
}

return false;
return unlink($path);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ public function testRemovesEntriesForKeyWithPurge()
{
$request = Request::create('/foo');
$this->store->write($request, new Response('foo'));
$this->assertNotEmpty($this->getStoreMetadata($request));

$metadata = $this->getStoreMetadata($request);
$this->assertNotEmpty($metadata);

$path = $this->store->getPath($metadata[0][1]['x-content-digest'][0]);
$this->assertTrue(is_file($path));

$this->assertTrue($this->store->purge('/foo'));
$this->assertEmpty($this->getStoreMetadata($request));
$this->assertFalse(is_file($path));

$this->assertFalse($this->store->purge('/bar'));
}
Expand Down
0