Skip to content

Commit 1b29555

Browse files
Implement redis configuration
1 parent dd0b023 commit 1b29555

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?php
2+
3+
4+
namespace Hypernode\DeployConfiguration\PlatformConfiguration;
5+
6+
7+
use Hypernode\DeployConfiguration\ServerRoleConfigurableInterface;
8+
use Hypernode\DeployConfiguration\ServerRoleConfigurableTrait;
9+
use Hypernode\DeployConfiguration\StageConfigurableInterface;
10+
use Hypernode\DeployConfiguration\StageConfigurableTrait;
11+
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
12+
13+
class RedisConfiguration implements
14+
TaskConfigurationInterface,
15+
ServerRoleConfigurableInterface,
16+
StageConfigurableInterface
17+
{
18+
use ServerRoleConfigurableTrait;
19+
use StageConfigurableTrait;
20+
21+
/**
22+
* Defaults
23+
*/
24+
private const DEFAULT_PORT = 6379;
25+
private const DEFAULT_PERSISTENCE_PORT = 6378;
26+
private const DEFAULT_BACKEND_REDIS_DB = 0;
27+
private const DEFAULT_VERSION = '5.0';
28+
private const DEFAULT_MEMORY = 1024;
29+
30+
/**
31+
* @var int
32+
*/
33+
private $port;
34+
35+
/**
36+
* @var bool
37+
*/
38+
private $persistence;
39+
40+
/**
41+
* @var int
42+
*/
43+
private $backendDb;
44+
45+
/**
46+
* @var string
47+
*/
48+
private $version;
49+
50+
/**
51+
* @var int
52+
*/
53+
private $memory;
54+
55+
/**
56+
* @var bool
57+
*/
58+
private $useSupervisor;
59+
60+
/**
61+
* @param int $port
62+
* @param int $backendDb
63+
* @param string $version
64+
* @param int $memory
65+
* @param false $persistence
66+
* @param false $useSupervisor
67+
*/
68+
public function __construct(
69+
$port = self::DEFAULT_PORT,
70+
$backendDb = self::DEFAULT_BACKEND_REDIS_DB,
71+
$version = self::DEFAULT_VERSION,
72+
$memory = self::DEFAULT_MEMORY,
73+
$persistence = false,
74+
$useSupervisor = false
75+
) {
76+
$this->port = (self::DEFAULT_PORT && $persistence) ? self::DEFAULT_PERSISTENCE_PORT : $port;
77+
$this->backendDb = $backendDb;
78+
$this->version = $version;
79+
$this->memory = $memory;
80+
$this->persistence = $persistence;
81+
$this->useSupervisor = $useSupervisor;
82+
}
83+
84+
/**
85+
* @return int
86+
*/
87+
public function getPort(): int
88+
{
89+
return $this->port;
90+
}
91+
92+
/**
93+
* @return bool
94+
*/
95+
public function getPersistence(): bool
96+
{
97+
return $this->persistence;
98+
}
99+
100+
/**
101+
* @return int
102+
*/
103+
public function getBackendDb(): int
104+
{
105+
return $this->backendDb;
106+
}
107+
108+
/**
109+
* @return string
110+
*/
111+
public function getVersion(): string
112+
{
113+
return $this->version;
114+
}
115+
116+
/**
117+
* @return int
118+
*/
119+
public function getMemory(): int
120+
{
121+
return $this->memory;
122+
}
123+
124+
/**
125+
* @return bool
126+
*/
127+
public function getUseSupervisor(): bool
128+
{
129+
return $this->useSupervisor;
130+
}
131+
}

0 commit comments

Comments
 (0)