Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / diviner / cache / DivinerPublishCache.php
blob1b3859b3e9170cfbf4b7c5774fe7afbc52b6eebc
1 <?php
3 final class DivinerPublishCache extends DivinerDiskCache {
5 private $pathMap;
6 private $index;
8 public function __construct($cache_directory) {
9 parent::__construct($cache_directory, 'diviner-publish-cache');
13 /* -( Path Map )----------------------------------------------------------- */
16 public function getPathMap() {
17 if ($this->pathMap === null) {
18 $this->pathMap = $this->getCache()->getKey('path', array());
20 return $this->pathMap;
23 public function writePathMap() {
24 $this->getCache()->setKey('path', $this->getPathMap());
27 public function getAtomPathsFromCache($hash) {
28 return idx($this->getPathMap(), $hash, array());
31 public function removeAtomPathsFromCache($hash) {
32 $map = $this->getPathMap();
33 unset($map[$hash]);
34 $this->pathMap = $map;
35 return $this;
38 public function addAtomPathsToCache($hash, array $paths) {
39 $map = $this->getPathMap();
40 $map[$hash] = $paths;
41 $this->pathMap = $map;
42 return $this;
46 /* -( Index )-------------------------------------------------------------- */
49 public function getIndex() {
50 if ($this->index === null) {
51 $this->index = $this->getCache()->getKey('index', array());
53 return $this->index;
56 public function writeIndex() {
57 $this->getCache()->setKey('index', $this->getIndex());
60 public function deleteAtomFromIndex($hash) {
61 $index = $this->getIndex();
62 unset($index[$hash]);
63 $this->index = $index;
64 return $this;
67 public function addAtomToIndex($hash, array $data) {
68 $index = $this->getIndex();
69 $index[$hash] = $data;
70 $this->index = $index;
71 return $this;