Skip to content

flush all cache through artisan, and typo #60

New issue

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

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

Already on GitHub? # to your account

Closed
vesper8 opened this issue Jan 16, 2018 · 7 comments
Closed

flush all cache through artisan, and typo #60

vesper8 opened this issue Jan 16, 2018 · 7 comments
Assignees

Comments

@vesper8
Copy link
Contributor

vesper8 commented Jan 16, 2018

php artisan modelCaching:flush --model=App\Model

should be

php artisan modelCache:flush --model=App\Model

And I noticed that you HAVE to specify a model.. it would be very preferable to being able to flush all of the modelCache.. without having to flush the entire redis cache

could this be added please?

@vesper8
Copy link
Contributor Author

vesper8 commented Jan 16, 2018

Furthermore I just tested flushing a model and noticed you have to provide double slashes on the command line:

php artisan modelCache:flush --model=\MyVendor\MyModule\Models\MyModel

fails

but

php artisan modelCache:flush --model=\\MyVendor\\MyModule\\Models\\MyModel

works

@mikebronner
Copy link
Owner

yes, the double-slashes is expected. :)
Regarding flushing only model caching when you don't provide a model, I don't see that being implemented at the moment, due to the complexity involved of figuring out which models are cached models, and then to iterate through them and flush each one individually.

If you can submit a PR to get this expedited, that would help. I'll definitely keep it on the radar for future consideration, though. Thanks! :)

@mikebronner
Copy link
Owner

I added this now in version 0.2.33. To achieve this, I recommend setting up a dedicated cache connection for laravel-model-cache, then use the php artisan modelCache:flush command. Let me know how that works.

@vesper8
Copy link
Contributor Author

vesper8 commented Feb 20, 2018

Thanks for implementing this @mikebronner but I have a few concerns about it

First of all shouldn't config('laravel-model-caching:store') be config('laravel-model-caching.store') ? Does config work with either : or . ? I never tried it with :

Also.. I see that you don't provide any default value in your configuration file, instead you just use env('MODEL_CACHE_STORE') which isn't an existing env variable. What is supposed to be this value? A connection name?

So what will happen if someone tries to run this and they haven't configured this variable? What would happen then?

Also.. you recommend setting a dedicated cache connection.. is that a requirement or a recommendation? What will happen if one doesn't do that.. will it flush more than just the part of the cache occupied by this package?

@mikebronner
Copy link
Owner

mikebronner commented Feb 20, 2018

Hmm, let me look at the cache store configuration name issue. That might have been slipping by me this whole time. Thanks for noticing.
If you don't set up a dedicated cache store, it would flush the entire cache. I was just thinking I should elaborate on this in the documentation.

@mikebronner
Copy link
Owner

Hi @vesper8 , could you try again using release 0.2.34? I have gone through and done some refactoring and quite a bit of cleanup. Please let me know how that works for you. :)

I will be updating the readme tomorrow with more details on the updates to flush the cache, as well as some other changes in this release. Thanks for being patient. :)

@mikebronner mikebronner removed this from the 0.3.0 milestone Feb 24, 2018
@mikebronner
Copy link
Owner

@vesper8 closing this for now, please let me know if you continue to have this problem.

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

No branches or pull requests

3 participants