06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Cache 282<br />

1 $john = Cache::tags(['people', 'artists'])->get('John');<br />

2<br />

3 $anne = Cache::tags(['people', 'authors'])->get('Anne');<br />

You may flush all items that are assigned a tag or list of tags. For example, this statement would<br />

remove all caches tagged with either people, authors, or both. So, both Anne and John would be<br />

removed from the cache:<br />

1 Cache::tags(['people', 'authors'])->flush();<br />

In contrast, this statement would remove only caches tagged with authors, so Anne would be<br />

removed, but not John.<br />

1 Cache::tags('authors')->flush();<br />

Adding Custom Cache Drivers<br />

To extend the Laravel cache with a custom driver, we will use the extend method on the Cache<br />

facade, which is used to bind a custom driver resolver to the manager. Typically, this is done within<br />

a service provider.<br />

For example, to register a new cache driver named “mongo”:<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!