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
Copy file name to clipboardExpand all lines: README.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,24 +135,9 @@ class Kid extends Model
135
135
Kid::flushQueryCache();
136
136
```
137
137
138
-
## Relationship Caching
139
-
140
-
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.
141
-
142
-
```php
143
-
$user = User::with(['orders' => function ($query) {
144
-
return $query
145
-
->cacheFor(60 * 60)
146
-
->cacheTags(['my:orders']);
147
-
}])->get();
148
-
149
-
// This comes from the cache if existed.
150
-
$orders = $user->orders;
151
-
```
152
-
153
138
## Full Automatic Invalidation
154
139
155
-
To speed up the scaffolding of invalidation within your app, you can specify the model to auto-flush the cache upon any model gets created, updated or deleted.
140
+
To speed up the scaffolding of invalidation within your app, you can specify the model to auto-flush the cache upon any time records gets created, updated or deleted.
156
141
157
142
```php
158
143
class Page extends Model
@@ -224,6 +209,21 @@ $page->update([
224
209
225
210
**Not specifying a tag to invalidate fallbacks to the set of base tags, thus leading to Full Automatic Invalidation.**
226
211
212
+
## Relationship Caching
213
+
214
+
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.
215
+
216
+
```php
217
+
$user = User::with(['orders' => function ($query) {
218
+
return $query
219
+
->cacheFor(60 * 60)
220
+
->cacheTags(['my:orders']);
221
+
}])->get();
222
+
223
+
// This comes from the cache if existed.
224
+
$orders = $user->orders;
225
+
```
226
+
227
227
## Cache Keys
228
228
229
229
The package automatically generate the keys needed to store the data in the cache store. However, prefixing them might be useful if the cache store is used by other applications and/or models and you want to manage the keys better to avoid collisions.
0 commit comments