protected function cached(string $key, Closure $dataGetter)
    {
        if ($this->cacheRepository->has($key)) {
            return $this->cacheRepository->get($key);
        }
        $result = $dataGetter();
        $this->cacheRepository->put($key, $result, $this->cacheTimeout);
        return $result;
    }
protected function cached(string $key, Closure $dataGetter)
    {
        if ($this->cacheRepository->has($key)) {
            return $this->cacheRepository->get($key);
        }
        $result = $dataGetter();
        $this->cacheRepository->put($key, $result, $this->cacheTimeout);
        return $result;
    }
protected function cached ( string $ key , Closure $ dataGetter ) { if ( $ this -> cacheRepository -> has ( $ key ) ) { return $ this -> cacheRepository -> get ( $ key ) ; } $ result = $ dataGetter ( ) ; $ this -> cacheRepository -> put ( $ key , $ result , $ this -> cacheTimeout ) ; return $ result ; }
Get data from cache.
If it not exists in cache got it in repository and store in cache.

@param string $key Key to find data in cache
@param Closure $dataGetter Function to get data in original repository

@return mixed
Get data from cache . If it not exists in cache got it in repository and store in cache .