CacheTool\CacheTool::factory PHP Method

factory() public static method

public static factory ( AbstractAdapter $adapter = null, string $tempDir = null, Psr\Log\LoggerInterface $logger = null ) : CacheTool
$adapter CacheTool\Adapter\AbstractAdapter
$tempDir string
$logger Psr\Log\LoggerInterface
return CacheTool
    public static function factory(AbstractAdapter $adapter = null, $tempDir = null, LoggerInterface $logger = null)
    {
        $cacheTool = new static($tempDir, $logger);
        $cacheTool->addProxy(new Proxy\ApcProxy());
        $cacheTool->addProxy(new Proxy\ApcuProxy());
        $cacheTool->addProxy(new Proxy\PhpProxy());
        $cacheTool->addProxy(new Proxy\OpcacheProxy());
        if ($adapter instanceof AbstractAdapter) {
            $cacheTool->setAdapter($adapter);
        }
        return $cacheTool;
    }

Usage Example

Beispiel #1
0
 public function testFactoryWithAdapterAndLogger()
 {
     $adapter = new Adapter\FastCGI();
     $logger = $this->getLogger();
     $cachetool = CacheTool::factory($adapter, null, $logger);
     $this->assertCount(4, $cachetool->getProxies());
     $this->assertSame($adapter, $cachetool->getAdapter());
     $this->assertSame($logger, $cachetool->getLogger());
 }
All Usage Examples Of CacheTool\CacheTool::factory