[HttpKernel] Remove destructive flush() from memcache(d) storage profilers

This commit is contained in:
Andrej Hudec 2012-04-27 22:40:33 +02:00
parent 4ac3bddb5d
commit e17217b14a
3 changed files with 30 additions and 7 deletions

View File

@ -95,7 +95,28 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface
*/ */
public function purge() public function purge()
{ {
$this->flush(); // delete only items from index
$indexName = $this->getIndexName();
$indexContent = $this->getValue($indexName);
if (!$indexContent) {
return false;
}
$profileList = explode("\n", $indexContent);
foreach ($profileList as $item) {
if ($item == '') {
continue;
}
if (false !== $pos = strpos($item, "\t")) {
$this->delete($this->getItemName(substr($item, 0, $pos)));
}
}
return $this->delete($indexName);
} }
/** /**
@ -172,11 +193,13 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface
abstract protected function setValue($key, $value, $expiration = 0); abstract protected function setValue($key, $value, $expiration = 0);
/** /**
* Flush all existing items at the memcache server * Delete item from the memcache server
*
* @param string $key
* *
* @return boolean * @return boolean
*/ */
abstract protected function flush(); abstract protected function delete($key);
/** /**
* Append data to an existing item on the memcache server * Append data to an existing item on the memcache server

View File

@ -69,9 +69,9 @@ class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function flush() protected function delete($key)
{ {
return $this->getMemcache()->flush(); return $this->getMemcache()->delete($key);
} }
/** /**

View File

@ -73,9 +73,9 @@ class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function flush() protected function delete($key)
{ {
return $this->getMemcached()->flush(); return $this->getMemcached()->delete($key);
} }
/** /**