refactor the memcached class.
This commit is contained in:
parent
07d6ed5703
commit
cb7a59711a
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue