Skip to content

Commit

Permalink
Update docs to reflect caching collections
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Feb 23, 2016
1 parent a71d812 commit 5679b86
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ Now, everything is in place. You might render your view, like so:

Notice the Russian-Doll style cascading for our caches; that's the key. If any note is updated, its individual cache will clear - along with its parent - but any siblings will remain untouched.

### Caching Collections

You won't always want to cache model instances; you may wish to cache a Laravel collection as well! No problem.

```html
@cache($posts)
@foreach ($posts as $post)
@include ('post')
@endforeach
@endcache
```

Now, as long as the `$posts` collection contents does not change, that `@foreach` section will never run. Instead, as always, we'll pull from the cache.

Behind the scenes, this package will detect that you've passed a Laravel collection to the `cache` directive, and will subsequently generate a unique cache key for the collection.

## FAQ

**1. Is there any way to override the cache key for a model instance?**
Expand Down

0 comments on commit 5679b86

Please sign in to comment.