Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 68f9acc

Browse files
author
Patrick McLain
committed
Update colinmollenhour/php-redis-session-abstract
* Update implementation of `Cm\RedisSession\Handler\ConfigInterface`
1 parent fa906ed commit 68f9acc

File tree

4 files changed

+121
-11
lines changed

4 files changed

+121
-11
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"colinmollenhour/cache-backend-file": "1.4",
3535
"colinmollenhour/cache-backend-redis": "1.10.2",
3636
"colinmollenhour/credis": "1.6",
37-
"colinmollenhour/php-redis-session-abstract": "~1.2.2",
37+
"colinmollenhour/php-redis-session-abstract": "~1.3.8",
3838
"composer/composer": "1.4.1",
3939
"magento/composer": "~1.2.0",
4040
"magento/magento-composer-installer": ">=0.1.11",
@@ -50,6 +50,7 @@
5050
"symfony/process": "~2.1",
5151
"tedivm/jshrink": "~1.1.0",
5252
"tubalmartin/cssmin": "4.1.0",
53+
"webonyx/graphql-php": "^0.11.1",
5354
"zendframework/zend-captcha": "^2.7.1",
5455
"zendframework/zend-code": "^3.1.0",
5556
"zendframework/zend-config": "^2.6.0",
@@ -75,8 +76,7 @@
7576
"zendframework/zend-text": "^2.6.0",
7677
"zendframework/zend-uri": "^2.5.1",
7778
"zendframework/zend-validator": "^2.6.0",
78-
"zendframework/zend-view": "^2.8.1",
79-
"webonyx/graphql-php": "^0.11.1"
79+
"zendframework/zend-view": "^2.8.1"
8080
},
8181
"require-dev": {
8282
"friendsofphp/php-cs-fixer": "~2.1.1",

composer.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/internal/Magento/Framework/Session/SaveHandler/Redis/Config.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,26 @@ class Config implements \Cm\RedisSession\Handler\ConfigInterface
100100
*/
101101
const PARAM_BREAK_AFTER = 'session/redis/break_after';
102102

103+
/**
104+
* Configuration path for comma separated list of sentinel servers
105+
*/
106+
const PARAM_SENTINEL_SERVERS = 'session/redis/sentinel_servers';
107+
108+
/**
109+
* Configuration path for sentinel master
110+
*/
111+
const PARAM_SENTINEL_MASTER = 'session/redis/sentinel_master';
112+
113+
/**
114+
* Configuration path for verify sentinel master flag
115+
*/
116+
const PARAM_SENTINEL_VERIFY_MASTER = 'session/redis/sentinel_verify_master';
117+
118+
/**
119+
* Configuration path for number of sentinel connection retries
120+
*/
121+
const PARAM_SENTINEL_CONNECT_RETRIES = 'session/redis/sentinel_connect_retries';
122+
103123
/**
104124
* Cookie lifetime config path
105125
*/
@@ -115,6 +135,11 @@ class Config implements \Cm\RedisSession\Handler\ConfigInterface
115135
*/
116136
const SESSION_MAX_LIFETIME = 31536000;
117137

138+
/**
139+
* Try to break lock for at most this many seconds
140+
*/
141+
const DEFAULT_FAIL_AFTER = 15;
142+
118143
/**
119144
* Deployment config
120145
*
@@ -293,4 +318,44 @@ public function getLifetime()
293318
}
294319
return (int)$this->scopeConfig->getValue(self::XML_PATH_COOKIE_LIFETIME, StoreScopeInterface::SCOPE_STORE);
295320
}
321+
322+
/**
323+
* {@inheritdoc}
324+
*/
325+
public function getSentinelServers()
326+
{
327+
return $this->deploymentConfig->get(self::PARAM_SENTINEL_SERVERS);
328+
}
329+
330+
/**
331+
* {@inheritdoc}
332+
*/
333+
public function getSentinelMaster()
334+
{
335+
return $this->deploymentConfig->get(self::PARAM_SENTINEL_MASTER);
336+
}
337+
338+
/**
339+
* {@inheritdoc}
340+
*/
341+
public function getSentinelVerifyMaster()
342+
{
343+
return $this->deploymentConfig->get(self::PARAM_SENTINEL_VERIFY_MASTER);
344+
}
345+
346+
/**
347+
* {@inheritdoc}
348+
*/
349+
public function getSentinelConnectRetries()
350+
{
351+
return $this->deploymentConfig->get(self::PARAM_SENTINEL_CONNECT_RETRIES);
352+
}
353+
354+
/**
355+
* {@inheritdoc}
356+
*/
357+
public function getFailAfter()
358+
{
359+
return self::DEFAULT_FAIL_AFTER;
360+
}
296361
}

lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/ConfigTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,49 @@ public function testGetLifetimeFrontend()
246246
->willReturn($expectedLifetime);
247247
$this->assertEquals($this->config->getLifetime(), $expectedLifetime);
248248
}
249+
250+
public function testGetSentinelServers()
251+
{
252+
$expected = 'server-1,server-2';
253+
$this->deploymentConfigMock->expects($this->once())
254+
->method('get')
255+
->with(Config::PARAM_SENTINEL_SERVERS)
256+
->willReturn($expected);
257+
$this->assertEquals($expected, $this->config->getSentinelServers());
258+
}
259+
260+
public function testGetSentinelMaster()
261+
{
262+
$expected = 'master';
263+
$this->deploymentConfigMock->expects($this->once())
264+
->method('get')
265+
->with(Config::PARAM_SENTINEL_MASTER)
266+
->willReturn($expected);
267+
$this->assertEquals($this->config->getSentinelMaster(), $expected);
268+
}
269+
270+
public function testGetSentinelVerifyMaster()
271+
{
272+
$expected = '1';
273+
$this->deploymentConfigMock->expects($this->once())
274+
->method('get')
275+
->with(Config::PARAM_SENTINEL_VERIFY_MASTER)
276+
->willReturn($expected);
277+
$this->assertEquals($this->config->getSentinelVerifyMaster(), $expected);
278+
}
279+
280+
public function testGetSentinelConnectRetries()
281+
{
282+
$expected = '10';
283+
$this->deploymentConfigMock->expects($this->once())
284+
->method('get')
285+
->willReturn(Config::PARAM_SENTINEL_CONNECT_RETRIES)
286+
->willReturn($expected);
287+
$this->assertEquals($this->config->getSentinelConnectRetries(), $expected);
288+
}
289+
290+
public function testGetFailAfter()
291+
{
292+
$this->assertEquals($this->config->getFailAfter(), Config::DEFAULT_FAIL_AFTER);
293+
}
249294
}

0 commit comments

Comments
 (0)