Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] Restrict flushes to namespace scopes #18176

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

Merged
merged 1 commit into from
Mar 15, 2016
Merged
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
4 changes: 3 additions & 1 deletion src/Symfony/Component/Cache/Adapter/ApcuAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ protected function doHave($id)
*/
protected function doClear($namespace)
{
return apcu_clear_cache();
return isset($namespace[0]) && class_exists('APCuIterator', false)
? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY))
: apcu_clear_cache();
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class DoctrineAdapter extends AbstractAdapter

public function __construct(CacheProvider $provider, $defaultLifetime = 0, $namespace = '')
{
parent::__construct($namespace, $defaultLifetime);
parent::__construct('', $defaultLifetime);
$this->provider = $provider;
$provider->setNamespace($namespace);
}

/**
Expand All @@ -47,7 +48,11 @@ protected function doHave($id)
*/
protected function doClear($namespace)
{
return $this->provider->flushAll();
$namespace = $this->provider->getNamespace();

return isset($namespace[0])
? $this->provider->deleteAll()
: $this->provider->flushAll();
}

/**
Expand Down