-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Expand file tree
/
Copy pathConfig.php
More file actions
291 lines (249 loc) · 6.88 KB
/
Copy pathConfig.php
File metadata and controls
291 lines (249 loc) · 6.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Session\SaveHandler\Redis;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface as StoreScopeInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\State;
/**
* Redis session save handler
*/
class Config implements \Cm\RedisSession\Handler\ConfigInterface
{
/**
* Configuration path for log level
*/
const PARAM_LOG_LEVEL = 'session/redis/log_level';
/**
* Configuration path for host
*/
const PARAM_HOST = 'session/redis/host';
/**
* Configuration path for port
*/
const PARAM_PORT = 'session/redis/port';
/**
* Configuration path for database
*/
const PARAM_DATABASE = 'session/redis/database';
/**
* Configuration path for password
*/
const PARAM_PASSWORD = 'session/redis/password';
/**
* Configuration path for connection timeout
*/
const PARAM_TIMEOUT = 'session/redis/timeout';
/**
* Configuration path for persistent identifier
*/
const PARAM_PERSISTENT_IDENTIFIER = 'session/redis/persistent_identifier';
/**
* Configuration path for compression threshold
*/
const PARAM_COMPRESSION_THRESHOLD = 'session/redis/compression_threshold';
/**
* Configuration path for compression library
*/
const PARAM_COMPRESSION_LIBRARY = 'session/redis/compression_library';
/**
* Configuration path for maximum number of processes that can wait for a lock on one session
*/
const PARAM_MAX_CONCURRENCY = 'session/redis/max_concurrency';
/**
* Configuration path for minimum session lifetime
*/
const PARAM_MAX_LIFETIME = 'session/redis/max_lifetime';
/**
* Configuration path for min
*/
const PARAM_MIN_LIFETIME = 'session/redis/min_lifetime';
/**
* Configuration path for disabling session locking entirely flag
*/
const PARAM_DISABLE_LOCKING = 'session/redis/disable_locking';
/**
* Configuration path for lifetime of session for bots on subsequent writes
*/
const PARAM_BOT_LIFETIME = 'session/redis/bot_lifetime';
/**
* Configuration path for lifetime of session for bots on the first write
*/
const PARAM_BOT_FIRST_LIFETIME = 'session/redis/bot_first_lifetime';
/**
* Configuration path for lifetime of session for non-bots on the first write
*/
const PARAM_FIRST_LIFETIME = 'session/redis/first_lifetime';
/**
* Configuration path for number of seconds to wait before trying to break the lock
*/
const PARAM_BREAK_AFTER = 'session/redis/break_after';
/**
* Cookie lifetime config path
*/
const XML_PATH_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';
/**
* Admin session lifetime config path
*/
const XML_PATH_ADMIN_SESSION_LIFETIME = 'admin/security/session_lifetime';
/**
* Session max lifetime
*/
const SESSION_MAX_LIFETIME = 31536000;
/**
* Deployment config
*
* @var DeploymentConfig $deploymentConfig
*/
private $deploymentConfig;
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;
/**
* @param DeploymentConfig $deploymentConfig
* @param State $appState
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
DeploymentConfig $deploymentConfig,
State $appState,
ScopeConfigInterface $scopeConfig
) {
$this->deploymentConfig = $deploymentConfig;
$this->appState = $appState;
$this->scopeConfig = $scopeConfig;
}
/**
* {@inheritdoc}
*/
public function getLogLevel()
{
return $this->deploymentConfig->get(self::PARAM_LOG_LEVEL);
}
/**
* {@inheritdoc}
*/
public function getHost()
{
return $this->deploymentConfig->get(self::PARAM_HOST);
}
/**
* {@inheritdoc}
*/
public function getPort()
{
return $this->deploymentConfig->get(self::PARAM_PORT);
}
/**
* {@inheritdoc}
*/
public function getDatabase()
{
return $this->deploymentConfig->get(self::PARAM_DATABASE);
}
/**
* {@inheritdoc}
*/
public function getPassword()
{
return $this->deploymentConfig->get(self::PARAM_PASSWORD);
}
/**
* {@inheritdoc}
*/
public function getTimeout()
{
return $this->deploymentConfig->get(self::PARAM_TIMEOUT);
}
/**
* {@inheritdoc}
*/
public function getPersistentIdentifier()
{
return $this->deploymentConfig->get(self::PARAM_PERSISTENT_IDENTIFIER);
}
/**
* {@inheritdoc}
*/
public function getCompressionThreshold()
{
return $this->deploymentConfig->get(self::PARAM_COMPRESSION_THRESHOLD);
}
/**
* {@inheritdoc}
*/
public function getCompressionLibrary()
{
return $this->deploymentConfig->get(self::PARAM_COMPRESSION_LIBRARY);
}
/**
* {@inheritdoc}
*/
public function getMaxConcurrency()
{
return $this->deploymentConfig->get(self::PARAM_MAX_CONCURRENCY);
}
/**
* {@inheritdoc}
*/
public function getMaxLifetime()
{
return self::SESSION_MAX_LIFETIME;
}
/**
* {@inheritdoc}
*/
public function getMinLifetime()
{
return $this->deploymentConfig->get(self::PARAM_MIN_LIFETIME);
}
/**
* {@inheritdoc}
*/
public function getDisableLocking()
{
return $this->deploymentConfig->get(self::PARAM_DISABLE_LOCKING);
}
/**
* {@inheritdoc}
*/
public function getBotLifetime()
{
return $this->deploymentConfig->get(self::PARAM_BOT_LIFETIME);
}
/**
* {@inheritdoc}
*/
public function getBotFirstLifetime()
{
return $this->deploymentConfig->get(self::PARAM_BOT_FIRST_LIFETIME);
}
/**
* {@inheritdoc}
*/
public function getFirstLifetime()
{
return $this->deploymentConfig->get(self::PARAM_FIRST_LIFETIME);
}
/**
* {@inheritdoc}
*/
public function getBreakAfter()
{
return $this->deploymentConfig->get(self::PARAM_BREAK_AFTER . '_' . $this->appState->getAreaCode());
}
/**
* {@inheritdoc}
*/
public function getLifetime()
{
if ($this->appState->getAreaCode() == \Magento\Framework\App\Area::AREA_ADMINHTML) {
return (int)$this->scopeConfig->getValue(self::XML_PATH_ADMIN_SESSION_LIFETIME);
}
return (int)$this->scopeConfig->getValue(self::XML_PATH_COOKIE_LIFETIME, StoreScopeInterface::SCOPE_STORE);
}
}