Skip to content

Commit e76823f

Browse files
Merge pull request #17 from ByteInternet/redis-platform-configuration
Implement redis platform configuration
2 parents f134c56 + 0111212 commit e76823f

File tree

1 file changed

+129
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)