Skip to content

Commit 762e10d

Browse files
committed
removed extra flush logic
1 parent ed054d9 commit 762e10d

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ protected function doHave($id)
107107
return $this->client->get($id) !== false
108108
|| $this->client->getResultCode() === \Memcached::RES_SUCCESS;
109109
}
110+
110111
/**
111112
* {@inheritdoc}
112113
*/
113114
protected function doDelete(array $ids)
114115
{
115116
$toDelete = count($ids);
116-
foreach ((array) $this->client->deleteMulti($ids) as $result) {
117-
if (true === $result || \Memcached::RES_NOTFOUND === $result) {
117+
foreach ($this->client->deleteMulti($ids) as $result) {
118+
if (\Memcached::RES_SUCCESS === $result || \Memcached::RES_NOTFOUND === $result) {
118119
--$toDelete;
119120
}
120121
}
@@ -127,27 +128,7 @@ protected function doDelete(array $ids)
127128
*/
128129
protected function doClear($namespace)
129130
{
130-
if (!isset($namespace[0]) || false === $ids = $this->getIdsByPrefix($namespace)) {
131-
return $this->client->flush();
132-
}
133-
134-
$isCleared = true;
135-
do {
136-
$isCleared = $this->doDelete($ids) && $isCleared;
137-
} while ($ids = $this->getIdsByPrefix($namespace));
138-
139-
return $isCleared;
140-
}
141-
142-
private function getIdsByPrefix($namespace)
143-
{
144-
if (false === $ids = $this->client->getAllKeys()) {
145-
return false;
146-
}
147-
148-
return array_filter((array) $ids, function ($id) use ($namespace) {
149-
return 0 === strpos($id, $namespace);
150-
});
131+
return $this->client->flush();
151132
}
152133

153134
private function setOption($opt, $val)

0 commit comments

Comments
 (0)