From 83ab60922b7a69f67a9f27b9b8b8a979efa625e4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 14 Aug 2011 19:22:01 -0500 Subject: [PATCH] improving cache API documentation. --- system/cache.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/system/cache.php b/system/cache.php index 615e706b..140d8b08 100644 --- a/system/cache.php +++ b/system/cache.php @@ -47,6 +47,22 @@ public static function driver($driver = null) /** * Get an item from the cache. * + * If the cached item doesn't exist, the specified default value will be returned. + * + * + * // Get the "name" item from the cache + * $name = Cache::get('name'); + * + * // Get the "name" item, but return "Fred" if it doesn't exist + * $name = Cache::get('name', 'Fred'); + * + * + * The driver may also be specified: + * + * + * $name = Cache::get('name', null, 'memcached'); + * + * * @param string $key * @param mixed $default * @param string $driver @@ -66,6 +82,14 @@ public static function get($key, $default = null, $driver = null) * Get an item from the cache. If the item doesn't exist in the cache, store * the default value in the cache and return it. * + * + * // Get the name item. If it doesn't exist, store "Fred" for 30 minutes + * $name = Cache::remember('name', 'Fred', 30); + * + * // Closures may also be used as default values + * $name = Cache::remember('votes', function() {return Vote::count();}, 30); + * + * * @param string $key * @param mixed $default * @param int $minutes