Skip to content

Commit 4122c49

Browse files
committed
Small refactoring
1 parent e82fb0c commit 4122c49

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/RedisClient/Client/AbstractRedisClient.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ abstract class AbstractRedisClient {
4848
'clusters' => [],
4949
'init_on_start' => false,
5050
'init_on_error_moved' => false,
51-
'timeout_on_error_tryagain' => 0.25,
51+
'timeout_on_error_tryagain' => 0.05,
5252
],
5353
];
5454

@@ -102,12 +102,22 @@ protected function getConfig($param = null) {
102102
return isset($this->config[$param]) ? $this->config[$param] : null;
103103
}
104104

105+
/**
106+
* @param AbstractRedisClient $RedisClient
107+
* @param $config
108+
* @return \RedisClient\Protocol\ProtocolInterface
109+
*/
110+
protected function createProtocol(AbstractRedisClient $RedisClient, $config)
111+
{
112+
return ProtocolFactory::createRedisProtocol($RedisClient, $config);
113+
}
114+
105115
/**
106116
* @return ProtocolInterface
107117
*/
108118
protected function getProtocol() {
109119
if (!$this->Protocol) {
110-
$this->Protocol = ProtocolFactory::createRedisProtocol($this, $this->getConfig());
120+
$this->Protocol = $this->createProtocol($this, $this->getConfig());
111121
if ($this->ClusterMap) {
112122
$this->ClusterMap->addProtocol($this->Protocol);
113123
}
@@ -177,7 +187,7 @@ protected function executeProtocolCommand(ProtocolInterface $Protocol, array $co
177187
if ($response instanceof AskResponseException) {
178188
$config = $this->getConfig();
179189
$config['server'] = $response->getServer();
180-
$TempRedisProtocol = ProtocolFactory::createRedisProtocol($this, $config);
190+
$TempRedisProtocol = $this->createProtocol($this, $config);
181191
$TempRedisProtocol->send(['ASKING']);
182192
return $this->executeProtocolCommand($TempRedisProtocol, $command, $params);
183193
}
@@ -291,6 +301,7 @@ public function executeRaw($structure) {
291301
}
292302

293303
/**
304+
* @deprecated
294305
* Command will parsed by the client, before sent to server
295306
* @param string $command
296307
* @return mixed
@@ -300,6 +311,7 @@ public function executeRawString($command) {
300311
}
301312

302313
/**
314+
* @deprecated
303315
* @param string $command
304316
* @return string[]
305317
*/

src/RedisClient/ClientFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ClientFactory {
2525
const REDIS_VERSION_3x0 = '3.0';
2626
const REDIS_VERSION_3x2 = '3.2';
2727
const REDIS_VERSION_4x0 = '4.0';
28+
const REDIS_VERSION_DEFAULT = self::REDIS_VERSION_3x2;
2829

2930
/**
3031
* @var string|null
@@ -46,7 +47,7 @@ class ClientFactory {
4647
* @return string
4748
*/
4849
public static function getDefaultRedisVersion() {
49-
return self::$defaultRedisVersion ?: self::REDIS_VERSION_3x2;
50+
return self::$defaultRedisVersion ?: self::REDIS_VERSION_DEFAULT;
5051
}
5152

5253
/**

0 commit comments

Comments
 (0)