protected function _cache($videoId, $dl = false)
    {
        if ((!array_key_exists($videoId, static::$_cachedVideoData) || $dl)) {
            if ($videoId) {
                $videoData = BlockVideoCache::where('videoId', '=', $videoId)->first() ?: new BlockVideoCache;
                if (!$videoData->exists() || $dl) {
                    if ($videoInfo = $this->_dl('videos', ['id' => $videoId, 'part' => 'id,snippet'])) {
                        $videoData->videoId = $videoId;
                        $videoData->videoInfo = serialize($videoInfo);
                        $videoData->save();
                    }
                } else {
                    $videoInfo = unserialize($videoData->videoInfo);
                }
            } else {
                $videoInfo = null;
            }
            static::$_cachedVideoData[$videoId] = $videoInfo;
        }
        return static::$_cachedVideoData[$videoId];
    }
protected function _cache($videoId, $dl = false)
    {
        if ((!array_key_exists($videoId, static::$_cachedVideoData) || $dl)) {
            if ($videoId) {
                $videoData = BlockVideoCache::where('videoId', '=', $videoId)->first() ?: new BlockVideoCache;
                if (!$videoData->exists() || $dl) {
                    if ($videoInfo = $this->_dl('videos', ['id' => $videoId, 'part' => 'id,snippet'])) {
                        $videoData->videoId = $videoId;
                        $videoData->videoInfo = serialize($videoInfo);
                        $videoData->save();
                    }
                } else {
                    $videoInfo = unserialize($videoData->videoInfo);
                }
            } else {
                $videoInfo = null;
            }
            static::$_cachedVideoData[$videoId] = $videoInfo;
        }
        return static::$_cachedVideoData[$videoId];
    }
protected function _cache ( $ videoId , $ dl = false ) { if ( ( ! array_key_exists ( $ videoId , static :: $ _cachedVideoData ) || $ dl ) ) { if ( $ videoId ) { $ videoData = BlockVideoCache :: where ( 'videoId' , '=' , $ videoId ) -> first ( ) ? : new BlockVideoCache ; if ( ! $ videoData -> exists ( ) || $ dl ) { if ( $ videoInfo = $ this -> _dl ( 'videos' , [ 'id' => $ videoId , 'part' => 'id,snippet' ] ) ) { $ videoData -> videoId = $ videoId ; $ videoData -> videoInfo = serialize ( $ videoInfo ) ; $ videoData -> save ( ) ; } } else { $ videoInfo = unserialize ( $ videoData -> videoInfo ) ; } } else { $ videoInfo = null ; } static :: $ _cachedVideoData [ $ videoId ] = $ videoInfo ; } return static :: $ _cachedVideoData [ $ videoId ] ; }
Return cached youtube video API data or fetch if not cached
@param string $videoId
@param bool $dl
@return null|\stdClass https://developers.google.com/youtube/v3/docs/search#resource
Return cached youtube video API data or fetch if not cached