1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DoctrineORMModule\Options; |
6
|
|
|
|
7
|
|
|
use Laminas\Stdlib\AbstractOptions; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Configuration options for Second Level Cache |
11
|
|
|
*/ |
12
|
|
|
class SecondLevelCacheConfiguration extends AbstractOptions |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Enable the second level cache configuration |
16
|
|
|
* |
17
|
|
|
* @var bool |
18
|
|
|
*/ |
19
|
|
|
protected $enabled = false; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Default lifetime |
23
|
|
|
* |
24
|
|
|
* @var int |
25
|
|
|
*/ |
26
|
|
|
protected $defaultLifetime = 3600; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Default lock lifetime |
30
|
|
|
* |
31
|
|
|
* @var int |
32
|
|
|
*/ |
33
|
|
|
protected $defaultLockLifetime = 60; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The file lock region directory (needed for some cache usage) |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $fileLockRegionDirectory = ''; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Configure the lifetime and lock lifetime per region. You must pass an associative array like this: |
44
|
|
|
* |
45
|
|
|
* [ |
46
|
|
|
* 'My\Region' => ['lifetime' => 200, 'lock_lifetime' => 400], |
47
|
|
|
* ] |
48
|
|
|
* |
49
|
|
|
* @var mixed[] |
50
|
|
|
*/ |
51
|
|
|
protected $regions = []; |
52
|
|
|
|
53
|
1 |
|
public function setEnabled(bool $enabled) : void |
54
|
|
|
{ |
55
|
1 |
|
$this->enabled = (bool) $enabled; |
56
|
1 |
|
} |
57
|
|
|
|
58
|
86 |
|
public function isEnabled() : bool |
59
|
|
|
{ |
60
|
86 |
|
return $this->enabled; |
61
|
|
|
} |
62
|
|
|
|
63
|
1 |
|
public function setDefaultLifetime(int $defaultLifetime) : void |
64
|
|
|
{ |
65
|
1 |
|
$this->defaultLifetime = (int) $defaultLifetime; |
66
|
1 |
|
} |
67
|
|
|
|
68
|
1 |
|
public function getDefaultLifetime() : int |
69
|
|
|
{ |
70
|
1 |
|
return $this->defaultLifetime; |
71
|
|
|
} |
72
|
|
|
|
73
|
1 |
|
public function setDefaultLockLifetime(int $defaultLockLifetime) : void |
74
|
|
|
{ |
75
|
1 |
|
$this->defaultLockLifetime = (int) $defaultLockLifetime; |
76
|
1 |
|
} |
77
|
|
|
|
78
|
1 |
|
public function getDefaultLockLifetime() : int |
79
|
|
|
{ |
80
|
1 |
|
return $this->defaultLockLifetime; |
81
|
|
|
} |
82
|
|
|
|
83
|
1 |
|
public function setFileLockRegionDirectory(string $fileLockRegionDirectory) : void |
84
|
|
|
{ |
85
|
1 |
|
$this->fileLockRegionDirectory = (string) $fileLockRegionDirectory; |
86
|
1 |
|
} |
87
|
|
|
|
88
|
1 |
|
public function getFileLockRegionDirectory() : string |
89
|
|
|
{ |
90
|
1 |
|
return $this->fileLockRegionDirectory; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param mixed[] $regions |
95
|
|
|
*/ |
96
|
1 |
|
public function setRegions(array $regions) : void |
97
|
|
|
{ |
98
|
1 |
|
$this->regions = $regions; |
99
|
1 |
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return mixed[] |
103
|
|
|
*/ |
104
|
1 |
|
public function getRegions() : array |
105
|
|
|
{ |
106
|
1 |
|
return $this->regions; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|