Retrieve from cache if not empty, otherwise store results
of query in cache

@param  string   $key
@param  Builder  $query
@param  string   $verb Optional Builder verb to execute query

@return Collection|Model|array|null
490876
protected function cache($key, Builder $query, $verb = 'get')
    {
        $actualKey = $this->indexKey($key);

        $fetchData = function () use ($actualKey, $query, $verb) {
            $this->log('refreshing cache for '.get_class($this).' ('.$actualKey.')');

            return $this->callQueryVerb($query, $verb);
        };

        if ($this->enableCaching) {
            if ($this->cacheForMinutes > 0) {
                return CacheFacade::remember($actualKey, $this->cacheForMinutes, $fetchData);
            }

            return CacheFacade::rememberForever($actualKey, $fetchData);
        }

        return $fetchData();
    }
1279654
protected function query($verb, $uri, $parameters)
    {
        $this->ensureVhostDefined();

        return $this->httpClient->query($verb, $uri, $parameters);
    }
692971
public function toRoute($route = null, $params = array(), $query = array())
    {
        if(!$route)
            return $this->refresh();

        $url = $this->urlFactory->create($route, $params, $query);

        return $this->to($url);
    }
775498
public function scopeKey(Illuminate\Database\Query\Builder $query, $key)
    {
        return $query->whereKey($key);
    }
895092
public function process(QueryInterface $query)
    {
        if (!$query->isType(QueryInterface::TYPE_USE)) {
            return null;
        }

        $query = new UseQuery($query);
        $keyspace = $query->getDbName();
        $this->dsn->getConfig()->setKeyspace($keyspace);

        if ($this->client instanceof CachingClient) {
            $this->client->clearCache();
        }

        return new EmptyResult();
    }
422195
public function get($data, $fields = [], $key = null, $verb = 'geocode')
    {
        if ($key) $this->apiKey = $key;
        $request = $this->getRequest($data, $fields, $verb);
        return $this->newDataObject($request->getBody());
    }
986685
public function getByKey($key, \chilimatic\lib\datastructure\graph\filter\AbstractFilter $filter = null)
    {
        return $this->children->getByKey($key, $filter);
    }
597679
public function cache($result, $key, $duration = null)
    {
        if ($key && $this->getCache()) {
            $this->getCache()->set($key, $result, $duration);
        }
        return $result;
    }
62111
private function make($verb, $fetchDetails = null)
    {
        if (isset($this->cache[$verb])) {
            return $this->cache[$verb];
        }

        $data = $this->service->fetch(
            $this->word,
            $verb,
            is_null($fetchDetails) ? $this->prefetchDetails : (bool) $fetchDetails
        );

        if ($data === false) {
            return false;
        }
        $this->cache = array_merge($this->cache, $data);

        return $this->cache[$verb];
    }
645042
public function get($key, $default = null)
    {
        is_array($key)
            ? self::validateKeys($key)
            : self::validateKey($key);

        $this->queriesCount++;

        return ($tmp = $this->memcache->get($key)) === false
            ? false
            : unserialize($tmp);
    }
1374975
public function getQuery($key, $def = "", $filter = null)
    {
        $val = $this->query[$key];
        if ($filter) {
            $val = Filter::factory($val, $filter);
        }
        return $val === null ? $def : $val;
    }
16632
protected function setKeysForSaveQuery(Builder $query)
    {
        $query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery());

        return $query;
    }
225431
public function retrieve($query)
	{
		// Eager load configured relationships.
		$query = $this->setEagerLoaded($query);

		// Execute the query.
		$retrieved = $query->get();

		// Eager load configured relationships.
		return $this->setLazyLoaded($retrieved);
	}
1324486
public function get($object, $key, $cache=null)
    {
        if ($cache) {
            $schema = \Pheasant::instance()->schema($this->class);

            if ($cached = $cache->get($schema->hash($object, array(array($this->local, $this->foreign))))) {
                return $cached;
            }
        }

        if (($localValue = $object->{$this->local}) === null) {
            if($this->_allowEmpty) {
                return null;
            } else {
                throw new \Pheasant\Exception("Local value is null while not allowed");
            }
        }

        $result = $this->query("{$this->foreign}=?", $localValue)->execute();

        if(!count($result)) {
            if($this->_allowEmpty) {
                return null;
            } else {
                throw new \Pheasant\Exception("Failed to find a {$key} (via {$this->foreign}={$localValue})");
            }
        }

        return $this->hydrate($result->row());
    }
1356693
private function getQueryCacheHelper(\yii\db\Query $query, $key)
    {
        $data = $this->getHasCache($key);

        if ($data === false) {
            $data = $query->all();
            $this->setHasCache($key, $data);
        }

        return $data;
    }
1265805
public function request($verb, array $params = array())
    {
        if (! $this->url) {
            throw new RuntimeException("Cannot perform request when URL not set.  Use setUrl() method");
        }

        //Build the URL
        $params = array_merge(array('verb' => $verb), $params);
        $url = $this->url . (parse_url($this->url, PHP_URL_QUERY) ? '&' : '?') . http_build_query($params);

        //Do the request
        try {
            $resp = $this->httpAdapter->request($url);
            return $this->decodeResponse($resp);
        } catch (HttpException $e) {
            $this->checkForOaipmhException($e);
        }
    }
1187815
private static function addCached(CacheableInterface $verb, ResultInterface $result): void
    {
        self::$cache[$verb->getCacheKey()] = $result;
    }