merged skunkworks into develop.
This commit is contained in:
@@ -7,42 +7,38 @@ class Memcached {
|
||||
*
|
||||
* @var Memcache
|
||||
*/
|
||||
protected static $instance;
|
||||
protected static $connection;
|
||||
|
||||
/**
|
||||
* Get the Memcached connection instance.
|
||||
*
|
||||
* This connection will be managed as a singleton instance so that only
|
||||
* one connection to the Memcached severs will be established.
|
||||
* <code>
|
||||
* // Get the Memcache connection and get an item from the cache
|
||||
* $name = Memcached::connection()->get('name');
|
||||
*
|
||||
* // Get the Memcache connection and place an item in the cache
|
||||
* Memcached::connection()->set('name', 'Taylor');
|
||||
* </code>
|
||||
*
|
||||
* @return Memcache
|
||||
*/
|
||||
public static function instance()
|
||||
public static function connection()
|
||||
{
|
||||
if (is_null(static::$instance))
|
||||
if (is_null(static::$connection))
|
||||
{
|
||||
static::$instance = static::connect(Config::get('cache.memcached'));
|
||||
static::$connection = static::connect(Config::get('cache.memcached'));
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
return static::$connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Memcached connection instance.
|
||||
*
|
||||
* The configuration array passed to this method should be an array of
|
||||
* server hosts / ports, like those defined in the cache configuration
|
||||
* file.
|
||||
*
|
||||
* <code>
|
||||
* // Create a new localhost Memcached connection instance.
|
||||
* $memcache = Memcached::connect(array('host' => '127.0.0.1', 'port' => 11211));
|
||||
* </code>
|
||||
*
|
||||
* @param array $servers
|
||||
* @return Memcache
|
||||
*/
|
||||
public static function connect($servers)
|
||||
protected static function connect($servers)
|
||||
{
|
||||
$memcache = new \Memcache;
|
||||
|
||||
@@ -53,7 +49,7 @@ class Memcached {
|
||||
|
||||
if ($memcache->getVersion() === false)
|
||||
{
|
||||
throw new \RuntimeException('Could not establish memcached connection.');
|
||||
throw new \Exception('Could not establish memcached connection.');
|
||||
}
|
||||
|
||||
return $memcache;
|
||||
|
||||
Reference in New Issue
Block a user