Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cristal\ApiWrapper\Api::findOne doesn't utillize cache #28

Open
toddb02 opened this issue Oct 22, 2021 · 0 comments
Open

Cristal\ApiWrapper\Api::findOne doesn't utillize cache #28

toddb02 opened this issue Oct 22, 2021 · 0 comments

Comments

@toddb02
Copy link

toddb02 commented Oct 22, 2021

I was wondering if the findOne method in Cristal\ApiWrapper\Api purposely doesn't save to cache like the other find methods do. It does check if the cache key exists so it seems like more of an omission.

     * Call API for find entity of entrypoint.
     *
     * @param string $endpoint
     * @param int    $id
     * @param array  $filters
     *
     * @return array
     */
    protected function findOne(string $endpoint, $id, array $filters = [])
    {
        $uri = '/'.$endpoint.'/'.$id;
        $key = $uri.'?'.http_build_query($filters);
        if ($this->hasCache($key)) {
            return $this->getCache($key);
        }

        return $this->getTransport()->request($uri, $filters) ?? []; // <-- doesn't save to cache but checks for cache in above if statement
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant