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

Disable lada-cache for certains queries #80

Open
f-liva opened this issue Dec 12, 2019 · 8 comments
Open

Disable lada-cache for certains queries #80

f-liva opened this issue Dec 12, 2019 · 8 comments

Comments

@f-liva
Copy link

f-liva commented Dec 12, 2019

lada-cache on Laravel 6 is giving me some problem and sometimes the queries are not invalidated and subsequent queries to the database return inconsistent data.

I would therefore like to understand if it is possible to disable lada-cache for certain queries to the database, here is an example:

MyModel::withoutLadaCache()->updateOrCreate(...);

What do you think?

@spiritix
Copy link
Owner

L6 is not yet supported. We're working on it. As soon as it's released the mentioned problems should be gone. Do you think it's an actual use case that people might want to disable caching for specific queries? The library already offers an option to disable caching for specific tables.

@f-liva
Copy link
Author

f-liva commented Dec 13, 2019

Yes, I think the package should allow user to disable it programmately for certain queries, not for certain tables. There are operations I would do without pass trough lada-cache

@spiritix
Copy link
Owner

spiritix commented Dec 13, 2019

I am not sure if this could be implemented like you suggested, since there are many different ways to initiate a query in Laravel (from Models, from Eloquent, from Query Builder, etc.). Possibly we'd end up having something like this:

LadaCache::disable();
MyModel::orderBy('id')->get();
LadaCache::enable();

@f-liva
Copy link
Author

f-liva commented Dec 13, 2019

Yes this should be pefect!

@grishmadoshi
Copy link

Hello, I have similar issue.
For one of the table , there is one counter field which is updated frequently and clearing cache. So is this good idea to disable cache for it as suggested here. Can that have any impact on query where data are actually being read?

@vonec
Copy link

vonec commented Mar 7, 2021

any updates on this feature, it be great if we can implement

LadaCache::disable();
MyModel::orderBy('id')->get();
LadaCache::enable();

@spiritix
Copy link
Owner

Unfortunately I don't have the capacity to implement this at the moment. Contributions are welcome.

@liangguohuan
Copy link

This would help,but,it's better to be supported in lada-cache package

// disable cache all
\config(['lada-cache.active' => false]);
// disable specific tables
\config(['lada-cache.exclude-tables' => ['skus']]);
// clear specific model cache
app()->make('lada.handler')->setBuilder((new Sku())->getQuery())->invalidateQuery(Reflector::QUERY_TYPE_UPDATE);

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

No branches or pull requests

5 participants