You are here

public function RedisProfilerStorage::purge in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/Profiler/RedisProfilerStorage.php \Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage::purge()

Purges all data from the database.

Overrides ProfilerStorageInterface::purge

File

vendor/symfony/http-kernel/Profiler/RedisProfilerStorage.php, line 110

Class

RedisProfilerStorage
RedisProfilerStorage stores profiling information in Redis.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

public function purge() {

  // delete only items from index
  $indexName = $this
    ->getIndexName();
  $indexContent = $this
    ->getValue($indexName, self::REDIS_SERIALIZER_NONE);
  if (!$indexContent) {
    return false;
  }
  $profileList = explode("\n", $indexContent);
  $result = array();
  foreach ($profileList as $item) {
    if ($item == '') {
      continue;
    }
    if (false !== ($pos = strpos($item, "\t"))) {
      $result[] = $this
        ->getItemName(substr($item, 0, $pos));
    }
  }
  $result[] = $indexName;
  return $this
    ->delete($result);
}