From e467c831ccf37e02245e38ec3cb2e51909453bf9 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 16 Jun 2011 19:58:14 -0500 Subject: [PATCH] improve cache class documentation. --- system/cache.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/system/cache.php b/system/cache.php index c0a3dd2a..6113b906 100644 --- a/system/cache.php +++ b/system/cache.php @@ -17,19 +17,19 @@ class Cache { */ public static function driver($driver = null) { + // -------------------------------------------------- + // If the cache driver has already been instantiated, + // we'll just return that existing instance. + // + // Otherwise, we'll instantiate a new one. + // -------------------------------------------------- if ( ! array_key_exists($driver, static::$drivers)) { - // -------------------------------------------------- - // If no driver was specified, use the default. - // -------------------------------------------------- if (is_null($driver)) { $driver = Config::get('cache.driver'); } - // -------------------------------------------------- - // Create the cache driver. - // -------------------------------------------------- static::$drivers[$driver] = Cache\Factory::make($driver); } @@ -41,6 +41,13 @@ class Cache { */ public static function __callStatic($method, $parameters) { + // -------------------------------------------------- + // Passing method calls to the driver instance allows + // a better API for the developer. + // + // For instance, instead of saying Cache::driver()->foo(), + // we can now just say Cache::foo(). + // -------------------------------------------------- return call_user_func_array(array(static::driver(), $method), $parameters); }