src/Cache.php
private function analyseWithCache($headers, $options = [])
    {
        if (isset($options['cache'])) {
            if (isset($options['cacheExpires'])) {
                $this->setCache($options['cache'], $options['cacheExpires']);
            } else {
                $this->setCache($options['cache']);
            }
        }

        if ($this->cache instanceof CacheItemPoolInterface) {
            $item = $this->cache->getItem('whichbrowser_' . md5(serialize($headers)));

            if ($item->isHit()) {
                $this->applyCachedData($item->get());
            } else {
                $analyser = new Analyser($headers, $options);
                $analyser->setdata($this);
                $analyser->analyse();

                $item->set($this->retrieveCachedData());
                $item->expiresAfter($this->expires);
                $this->cache->save($item);
            }

            return true;
        }
    }
private function analyseWithCache($headers, $options = [])
    {
        if (isset($options['cache'])) {
            if (isset($options['cacheExpires'])) {
                $this->setCache($options['cache'], $options['cacheExpires']);
            } else {
                $this->setCache($options['cache']);
            }
        }

        if ($this->cache instanceof CacheItemPoolInterface) {
            $item = $this->cache->getItem('whichbrowser_' . md5(serialize($headers)));

            if ($item->isHit()) {
                $this->applyCachedData($item->get());
            } else {
                $analyser = new Analyser($headers, $options);
                $analyser->setdata($this);
                $analyser->analyse();

                $item->set($this->retrieveCachedData());
                $item->expiresAfter($this->expires);
                $this->cache->save($item);
            }

            return true;
        }
    }
private function analyseWithCache ( $ headers , $ options = [ ] ) { if ( isset ( $ options [ 'cache' ] ) ) { if ( isset ( $ options [ 'cacheExpires' ] ) ) { $ this -> setCache ( $ options [ 'cache' ] , $ options [ 'cacheExpires' ] ) ; } else { $ this -> setCache ( $ options [ 'cache' ] ) ; } } if ( $ this -> cache instanceof CacheItemPoolInterface ) { $ item = $ this -> cache -> getItem ( 'whichbrowser_' . md5 ( serialize ( $ headers ) ) ) ; if ( $ item -> isHit ( ) ) { $ this -> applyCachedData ( $ item -> get ( ) ) ; } else { $ analyser = new Analyser ( $ headers , $ options ) ; $ analyser -> setdata ( $ this ) ; $ analyser -> analyse ( ) ; $ item -> set ( $ this -> retrieveCachedData ( ) ) ; $ item -> expiresAfter ( $ this -> expires ) ; $ this -> cache -> save ( $ item ) ; } return true ; } }
Retrieve the result from the cache, or analyse and store in the cache

@internal

@param  array|string     $headers   An array with all of the headers or a string with just the User-Agent header

@return  boolean         did we actually retrieve or analyse results
Retrieve the result from the cache or analyse and store in the cache