29.07.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 194<br />

.<br />

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

Cache Events<br />

To execute code on every cache operation, you may listen for the events fired by the cache. Typically,<br />

you would place these event handlers within the boot method of your EventServiceProvider:<br />

.<br />

1 /**<br />

2 * Register any other events for your application.<br />

3 *<br />

4 * @param \Illuminate\Contracts\Events\Dispatcher $events<br />

5 * @return void<br />

6 */<br />

7 public function boot(DispatcherContract $events)<br />

8 {<br />

9 parent::boot($events);<br />

10<br />

11 $events->listen('cache.hit', function ($key, $value) {<br />

12 //<br />

13 });<br />

14<br />

15 $events->listen('cache.missed', function ($key) {<br />

16 //<br />

17 });<br />

18<br />

19 $events->listen('cache.write', function ($key, $value, $minutes) {<br />

20 //<br />

21 });<br />

22<br />

23 $events->listen('cache.delete', function ($key) {<br />

24 //<br />

25 });<br />

26 }

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

Saved successfully!

Ooh no, something went wrong!