Rename Predis\IConnectionSchemes to Predis\IConnectionFactory.

This commit is contained in:
Daniele Alessandri
2011-04-08 16:06:59 +02:00
parent 5527fc34e7
commit b22cb6f76d
5 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ name) and let Predis using it. __phpiredis__ is a C-based extension that wraps _
official Redis C client library) with a thin layer that exposes its features to PHP. You will now
get the benefits of a faster protocol parser just by adding a single line of code in your application:
Predis\Client::defineConnection('tcp', '\Predis\Network\PhpiredisConnection');
Predis\ConnectionFactory::define('tcp', '\Predis\Network\PhpiredisConnection');
As simple as it is, nothing will really change in the way you use the library in your application. So,
how fast is it now? There are not much improvements for inline or short bulk replies (e.g. _SET_ or
+5 -5
View File
@@ -11,13 +11,13 @@ use Predis\Profiles\IServerProfile;
class Client {
const VERSION = '0.7.0-dev';
private $_options, $_schemes, $_profile, $_connection;
private $_options, $_connectionFactory, $_profile, $_connection;
public function __construct($parameters = null, $options = null) {
$options = $this->filterOptions($options ?: new ClientOptions());
$this->_options = $options;
$this->_profile = $options->profile;
$this->_schemes = $options->connections;
$this->_connectionFactory = $options->connections;
$this->_connection = $this->initializeConnection($parameters);
}
@@ -60,7 +60,7 @@ class Client {
}
private function createConnection($parameters) {
$connection = $this->_schemes->newConnection($parameters);
$connection = $this->_connectionFactory->newConnection($parameters);
$this->pushInitCommands($connection);
return $connection;
}
@@ -87,8 +87,8 @@ class Client {
return $this->_options;
}
public function getSchemes() {
return $this->_schemes;
public function getConnectionFactory() {
return $this->_connectionFactory;
}
public function getClientFor($connectionAlias) {
+3 -3
View File
@@ -24,14 +24,14 @@ class ClientOptions {
'key_distribution' => new ClientKeyDistribution(),
'connections' => new CustomOption(array(
'default' => function() {
return new ConnectionSchemes();
return new ConnectionFactory();
},
'validate' => function($value) {
if ($value instanceof IConnectionSchemes) {
if ($value instanceof IConnectionFactory) {
return $value;
}
if (is_array($value)) {
return new ConnectionSchemes($value);
return new ConnectionFactory($value);
}
},
)),
@@ -2,7 +2,7 @@
namespace Predis;
class ConnectionSchemes implements IConnectionSchemes {
class ConnectionFactory implements IConnectionFactory {
private static $_globalSchemes;
private $_instanceSchemes = array();
@@ -2,6 +2,6 @@
namespace Predis;
interface IConnectionSchemes {
interface IConnectionFactory {
public function newConnection($parameters);
}