improving cache API documentation.

This commit is contained in:
Taylor Otwell 2011-08-14 19:22:01 -05:00
parent f72171f691
commit 83ab60922b
1 changed files with 24 additions and 0 deletions

View File

@ -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.
*
* <code>
* // 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');
* </code>
*
* The driver may also be specified:
*
* <code>
* $name = Cache::get('name', null, 'memcached');
* </code>
*
* @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.
*
* <code>
* // 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);
* </code>
*
* @param string $key
* @param mixed $default
* @param int $minutes