From f2e3774f172d80d4bca5da8b38b091285a632832 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 10 Mar 2015 19:17:38 -0500 Subject: [PATCH] fix all kinds of problems. --- cache.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/cache.md b/cache.md index ea34b39c25..986bece4d7 100644 --- a/cache.md +++ b/cache.md @@ -4,6 +4,7 @@ - [Cache Usage](#cache-usage) - [Increments & Decrements](#increments-and-decrements) - [Cache Tags](#cache-tags) +- [Cache Events](#cache-events) - [Database Cache](#database-cache) @@ -138,25 +139,25 @@ In contrast, this statement would remove only caches tagged with `authors`, so " Cache::tags('authors')->flush(); -## Cache events +## Cache Events -Cache actions can trigger events. You may for instance use `Event` listeners to access the following events. +To execute code on every cache operation, you may listen for the events fired by the cache: -A cache entry exists and has been hit: - - Event::listen('cache.hit', function($key, $value) { ... }); - -A cache entry has been asked but does not exist: - - Event::listen('cache.missed', function($key) { ... }); - -A cache entry has been set or updated. `$minutes` will be equal to `0` if no expiration duration is set: + Event::listen('cache.hit', function($key, $value) { + // + }); - Event::listen('cache.write', function($key, $value, $minutes) { ... }); + Event::listen('cache.missed', function($key) { + // + }); -A cache entry has been deleted: + Event::listen('cache.write', function($key, $value, $minutes) { + // + }); - Event::listen('cache.delete', function($key) { ... }); + Event::listen('cache.delete', function($key) { + // + }); ## Database Cache