Commit cb7a5971 authored by Taylor Otwell's avatar Taylor Otwell

refactor the memcached class.

parent 07d6ed57
...@@ -16,7 +16,15 @@ class Memcached { ...@@ -16,7 +16,15 @@ class Memcached {
*/ */
public static function instance() 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')) if ( ! class_exists('Memcache'))
{ {
...@@ -35,10 +43,7 @@ class Memcached { ...@@ -35,10 +43,7 @@ class Memcached {
throw new \Exception('Memcached is configured. However, no connections could be made. Please verify your memcached configuration.'); throw new \Exception('Memcached is configured. However, no connections could be made. Please verify your memcached configuration.');
} }
static::$instance = $memcache; return $memcache;
}
return static::$instance;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment