Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ad21a8c

Browse filesBrowse files
[Cache] Restrict flushes to namespace scopes
1 parent b19ce5e commit ad21a8c
Copy full SHA for ad21a8c

File tree

Expand file treeCollapse file tree

2 files changed

+10
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-3
lines changed

‎src/Symfony/Component/Cache/Adapter/ApcuAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/ApcuAdapter.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ protected function doHave($id)
5050
*/
5151
protected function doClear($namespace)
5252
{
53-
return apcu_clear_cache();
53+
return isset($namespace[0]) && class_exists('APCuIterator', false)
54+
? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/'))))
55+
: apcu_clear_cache();
5456
}
5557

5658
/**

‎src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ class DoctrineAdapter extends AbstractAdapter
2222

2323
public function __construct(CacheProvider $provider, $defaultLifetime = 0, $namespace = '')
2424
{
25-
parent::__construct($namespace, $defaultLifetime);
25+
parent::__construct('', $defaultLifetime);
2626
$this->provider = $provider;
27+
$provider->setNamespace($namespace);
2728
}
2829

2930
/**
@@ -47,7 +48,11 @@ protected function doHave($id)
4748
*/
4849
protected function doClear($namespace)
4950
{
50-
return $this->provider->flushAll();
51+
$namespace = $this->provider->getNamespace();
52+
53+
return isset($namespace[0])
54+
? $this->provider->deleteAll()
55+
: $this->provider->flushAll();
5156
}
5257

5358
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.