Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

setCacheLifetime issue in multiple queries #167

Open
rbruhn opened this issue Nov 5, 2017 · 1 comment
Open

setCacheLifetime issue in multiple queries #167

rbruhn opened this issue Nov 5, 2017 · 1 comment

Comments

@rbruhn
Copy link

rbruhn commented Nov 5, 2017

Want to warn some users if they see something strange happening.
When performing multiple queries on the same repo, same request, the setCacheLifetime remains in effect even if not set.

$repo->setCacheLifetime(0)
            ->whereNotNull('banner_file_name')
            ->limit($count)
            ->get($attributes);

The above will set the $this->cacheLifetime to zero, thus not caching.

$repo->whereHas('nfnWorkflows')
            ->orderBy('created_at', 'desc')
            ->limit(5)
            ->findAll($attributes);

Running another query on the same repo during the same request or script run, you might expect the above query to use the cache. However, it does not. Instead, the repo still sees the setCacheLifetime(0) and runs the query against the database. Since this package does not reset the cacheLifetime after each query, you have to do it manually by using setCacheLifetime(null) on the subsequent query.

@rjsworking
Copy link
Contributor

Hi @rbruhn

The same is true for setCacheDriver

Cheers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants