Skip to content

Commit 9e28bea

Browse files
committed
Updated readme
1 parent 4022350 commit 9e28bea

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,9 @@ class Kid extends Model
135135
Kid::flushQueryCache();
136136
```
137137

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-
153138
## Full Automatic Invalidation
154139

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.
156141

157142
```php
158143
class Page extends Model
@@ -224,6 +209,21 @@ $page->update([
224209

225210
**Not specifying a tag to invalidate fallbacks to the set of base tags, thus leading to Full Automatic Invalidation.**
226211

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+
227227
## Cache Keys
228228

229229
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

Comments
 (0)