DeviceDetector\DeviceDetector::getCache PHP Method

getCache() public method

Returns Cache object
public getCache ( ) : CacheProvider
return Doctrine\Common\Cache\CacheProvider
    public function getCache()
    {
        if (!empty($this->cache)) {
            return $this->cache;
        }
        return new StaticCache();
    }

Usage Example

 public function testCacheSetAndGet()
 {
     if (!extension_loaded('memcache') || !class_exists('\\Doctrine\\Common\\Cache\\MemcacheCache')) {
         $this->markTestSkipped('memcache not enabled');
     }
     $dd = new DeviceDetector();
     $memcacheServer = new \Memcache();
     $memcacheServer->connect('localhost', 11211);
     $dd->setCache(new \Doctrine\Common\Cache\MemcacheCache($memcacheServer));
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\MemcacheCache', $dd->getCache());
 }