refactor the memcached class.

This commit is contained in:
Taylor Otwell 2011-08-08 09:16:47 -05:00
parent 07d6ed5703
commit cb7a59711a
1 changed files with 25 additions and 20 deletions

View File

@ -16,7 +16,15 @@ class Memcached {
*/
public static function instance()
{
if (is_null(static::$instance))
return ( ! is_null(static::$instance)) ? static::$instance : static::$instance = static::connect();
}
/**
* Connect to the configured Memcached servers.
*
* @return Memcache
*/
private static function connect()
{
if ( ! class_exists('Memcache'))
{
@ -35,10 +43,7 @@ public static function instance()
throw new \Exception('Memcached is configured. However, no connections could be made. Please verify your memcached configuration.');
}
static::$instance = $memcache;
}
return static::$instance;
return $memcache;
}
}