Skip to content

Commit

Permalink
Minor clarification [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Feb 23, 2022
1 parent 9c7b14b commit 6eedc10
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ use App\Models\Article;
Article::latest('published_at')->take(10)->cache(false)->get();
```

Finally, you can bypass the cache entirely using the query builder `when()` and `unless()` methods easily, as these are totally compatible with the `cache()` method.

```php
use App\Models\Article;

Article::latest('published_at')->whereBelongsTo($user)->take(10)->unless(Auth::check(), function ($articles) {
// If the user is a guest, use the cache to show the latest articles of the given user.
$articles->cache();
})->get();
```

### Custom Cache Store

You can use any other Cache Store different from the application default by setting a third parameter, or a named parameter.
Expand Down

0 comments on commit 6eedc10

Please sign in to comment.