lighthouse
lighthouse copied to clipboard
Reset `lighthouse:query` cache in `lighthouse:clear-cache` command
Seems there is no way to reset lighthouse:query cache (related to #2017, #2018, #2031) that may be useful (eg if cached value unserialization will fail). Looks like lighthouse:clear-cache is a good place for this?
We have documentation about this, see https://lighthouse-php.com/master/performance/query-caching.html#query-caching.
Using php artisan cache:clear is admittedly quite coarse, it clears the entire cache every time. I don't think we should include that in lighthouse:clear-cache.
My understanding is that we could use a tagged cache to clear just the cached items that Lighthouse put there?
Tagging a query cache is easy to implement. But I don't see a real usage for it. It is required only when packages are updated. That's pretty rare. And I guess it's still better to clear all caches in this case.
Also not all cache drivers support tagging. So it should be disabled by default.
Anyway, this cache can be cleared using command php artisan cache:clear --tags[=TAGS] [<store>]. The user clearly understands what this command will do. While our command php artisan lighthouse:clear-query-cache will do the same, it won't be clear. The user might think it clears only query cache while in reality it purges either full store or all cache entries tagged with specified tags.
All in all:
- I don't think we need a
lighthouse:clear-query-cachecommand - We may add tagging if someone really needs it.
php artisan cache:clear
I thought about something like this, eg if "store" is defined and not equal to default it can be cleared by lighthouse:clear-cache.
it won't be clear
Yes, maybe.
We have documentation about this
Oh, I see...
I don't think we need a lighthouse:clear-query-cache command
Agreed, let's not add an extra command.
I think it makes sense for lighthouse:clear-cache to clear all caches that Lighthouse knows about. However, it should not touch caches that are unrelated to Lighthouse - php artisan cache:clear already does that by just clearing all caches.
If you want this feature, I am happy to accept a PR that:
- Optionally tags the query cache
- Clears the query cache by tag, if it uses one
The command will be inconsistent: in some cases it will delete query cache and in others it won't. Also people might use tagging for other purposes so there might be other cache entries that are tagged by the same tag as query cache.
The command will be inconsistent: in some cases it will delete query cache and in others it won't.
We can document this behaviour.
Also people might use tagging for other purposes so there might be other cache entries that are tagged by the same tag as query cache.
We can use a tag that is reasonably unique.