Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diviner/cache/DivinerPublishCache.php
12256 views
1
<?php
2
3
final class DivinerPublishCache extends DivinerDiskCache {
4
5
private $pathMap;
6
private $index;
7
8
public function __construct($cache_directory) {
9
parent::__construct($cache_directory, 'diviner-publish-cache');
10
}
11
12
13
/* -( Path Map )----------------------------------------------------------- */
14
15
16
public function getPathMap() {
17
if ($this->pathMap === null) {
18
$this->pathMap = $this->getCache()->getKey('path', array());
19
}
20
return $this->pathMap;
21
}
22
23
public function writePathMap() {
24
$this->getCache()->setKey('path', $this->getPathMap());
25
}
26
27
public function getAtomPathsFromCache($hash) {
28
return idx($this->getPathMap(), $hash, array());
29
}
30
31
public function removeAtomPathsFromCache($hash) {
32
$map = $this->getPathMap();
33
unset($map[$hash]);
34
$this->pathMap = $map;
35
return $this;
36
}
37
38
public function addAtomPathsToCache($hash, array $paths) {
39
$map = $this->getPathMap();
40
$map[$hash] = $paths;
41
$this->pathMap = $map;
42
return $this;
43
}
44
45
46
/* -( Index )-------------------------------------------------------------- */
47
48
49
public function getIndex() {
50
if ($this->index === null) {
51
$this->index = $this->getCache()->getKey('index', array());
52
}
53
return $this->index;
54
}
55
56
public function writeIndex() {
57
$this->getCache()->setKey('index', $this->getIndex());
58
}
59
60
public function deleteAtomFromIndex($hash) {
61
$index = $this->getIndex();
62
unset($index[$hash]);
63
$this->index = $index;
64
return $this;
65
}
66
67
public function addAtomToIndex($hash, array $data) {
68
$index = $this->getIndex();
69
$index[$hash] = $data;
70
$this->index = $index;
71
return $this;
72
}
73
74
}
75
76