Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/cache/spec/PhabricatorCacheSpec.php
12242 views
1
<?php
2
3
abstract class PhabricatorCacheSpec extends Phobject {
4
5
private $name;
6
private $isEnabled = false;
7
private $version;
8
private $clearCacheCallback = null;
9
private $issues = array();
10
11
private $usedMemory = 0;
12
private $totalMemory = 0;
13
private $entryCount = null;
14
15
public function setName($name) {
16
$this->name = $name;
17
return $this;
18
}
19
20
public function getName() {
21
return $this->name;
22
}
23
24
public function setIsEnabled($is_enabled) {
25
$this->isEnabled = $is_enabled;
26
return $this;
27
}
28
29
public function getIsEnabled() {
30
return $this->isEnabled;
31
}
32
33
public function setVersion($version) {
34
$this->version = $version;
35
return $this;
36
}
37
38
public function getVersion() {
39
return $this->version;
40
}
41
42
protected function newIssue($key) {
43
$issue = id(new PhabricatorSetupIssue())
44
->setIssueKey($key);
45
$this->issues[$key] = $issue;
46
47
return $issue;
48
}
49
50
public function getIssues() {
51
return $this->issues;
52
}
53
54
public function setUsedMemory($used_memory) {
55
$this->usedMemory = $used_memory;
56
return $this;
57
}
58
59
public function getUsedMemory() {
60
return $this->usedMemory;
61
}
62
63
public function setTotalMemory($total_memory) {
64
$this->totalMemory = $total_memory;
65
return $this;
66
}
67
68
public function getTotalMemory() {
69
return $this->totalMemory;
70
}
71
72
public function setEntryCount($entry_count) {
73
$this->entryCount = $entry_count;
74
return $this;
75
}
76
77
public function getEntryCount() {
78
return $this->entryCount;
79
}
80
81
protected function raiseInstallAPCIssue() {
82
$message = pht(
83
"Installing the PHP extension 'APC' (Alternative PHP Cache) will ".
84
"dramatically improve performance. Note that APC versions 3.1.14 and ".
85
"3.1.15 are broken; 3.1.13 is recommended instead.");
86
87
return $this
88
->newIssue('extension.apc')
89
->setShortName(pht('APC'))
90
->setName(pht("PHP Extension 'APC' Not Installed"))
91
->setMessage($message)
92
->addPHPExtension('apc');
93
}
94
95
protected function raiseEnableAPCIssue() {
96
$summary = pht('Enabling APC/APCu will improve performance.');
97
$message = pht(
98
'The APC or APCu PHP extensions are installed, but not enabled in your '.
99
'PHP configuration. Enabling these extensions will improve performance. '.
100
'Edit the "%s" setting to enable these extensions.',
101
'apc.enabled');
102
103
return $this
104
->newIssue('extension.apc.enabled')
105
->setShortName(pht('APC/APCu Disabled'))
106
->setName(pht('APC/APCu Extensions Not Enabled'))
107
->setSummary($summary)
108
->setMessage($message)
109
->addPHPConfig('apc.enabled');
110
}
111
112
public function setClearCacheCallback($callback) {
113
$this->clearCacheCallback = $callback;
114
return $this;
115
}
116
117
public function getClearCacheCallback() {
118
return $this->clearCacheCallback;
119
}
120
}
121
122