You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To invalidate all the cache for a specific model, use the `flushQueryCache` method without passing the tags.
96
+
97
+
The package automatically appends a list of tags, called **base tags** on each query coming from a model. It defaults to the full model class name.
98
+
99
+
In case you want to change the base tags, you can do so in your model.
100
+
101
+
```php
102
+
class Kid extends Model
103
+
{
104
+
use QueryCacheable;
105
+
106
+
/**
107
+
* Set the base cache tags that will be present
108
+
* on all queries.
109
+
*
110
+
* @return array
111
+
*/
112
+
protected function getCacheBaseTags(): array
113
+
{
114
+
return [
115
+
'custom_tag',
116
+
];
117
+
}
118
+
}
119
+
120
+
// Automatically works with `custom_tag`
121
+
Kid::flushQueryCache();
122
+
```
123
+
93
124
## Relationship Caching
94
125
Relationships are just another queries. They can be intercepted and modified before the database is hit with the query. The following example needs the `Order` model (or the model associated with the `orders` relationship) to include the `QueryCacheable` trait.
0 commit comments