Continue refactoring the memcache class.

This commit is contained in:
Taylor Otwell 2011-08-08 09:18:08 -05:00
parent cb7a59711a
commit 8a6b85175e
1 changed files with 4 additions and 3 deletions

View File

@ -16,15 +16,16 @@ class Memcached {
*/
public static function instance()
{
return ( ! is_null(static::$instance)) ? static::$instance : static::$instance = static::connect();
return ( ! is_null(static::$instance)) ? static::$instance : static::$instance = static::connect(Config::get('cache.servers'));
}
/**
* Connect to the configured Memcached servers.
*
* @param array $servers
* @return Memcache
*/
private static function connect()
private static function connect($servers)
{
if ( ! class_exists('Memcache'))
{
@ -33,7 +34,7 @@ private static function connect()
$memcache = new \Memcache;
foreach (Config::get('cache.servers') as $server)
foreach ($servers as $server)
{
$memcache->addServer($server['host'], $server['port'], true, $server['weight']);
}