Stash\Pool::clear PHP Method

clear() public method

public clear ( )
    public function clear()
    {
        if ($this->isDisabled) {
            return false;
        }
        try {
            $driver = $this->getDriver();
            if (isset($this->namespace)) {
                $normalizedNamespace = strtolower($this->namespace);
                $results = $driver->clear(array('cache', $normalizedNamespace)) && $driver->clear(array('sp', $normalizedNamespace));
            } else {
                $results = $driver->clear();
            }
        } catch (\Exception $e) {
            $this->isDisabled = true;
            $this->logException('Flushing Cache Pool caused exception.', $e);
            return false;
        }
        return $results;
    }

Usage Example

 public function testPoolClear()
 {
     $pool = new Pool();
     $pool->setDriver(new DriverExceptionStub());
     $item = $pool->getItem('test');
     $this->assertFalse($item->isDisabled());
     $this->assertFalse($pool->clear());
     $item = $pool->getItem('test');
     $this->assertTrue($item->isDisabled(), 'Is disabled after exception is thrown in driver');
     $this->assertFalse($pool->clear());
 }
All Usage Examples Of Stash\Pool::clear