Path: blob/master/src/applications/diviner/cache/DivinerDiskCache.php
12256 views
<?php12abstract class DivinerDiskCache extends Phobject {34private $cache;56public function __construct($cache_directory, $name) {7$dir_cache = id(new PhutilDirectoryKeyValueCache())8->setCacheDirectory($cache_directory);9$profiled_cache = id(new PhutilKeyValueCacheProfiler($dir_cache))10->setProfiler(PhutilServiceProfiler::getInstance())11->setName($name);12$this->cache = $profiled_cache;13}1415protected function getCache() {16return $this->cache;17}1819public function delete() {20$this->getCache()->destroyCache();21return $this;22}2324/**25* Convert a long-form hash key like `ccbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaN` into26* a shortened directory form, like `cc/bb/aaaaaaaaN`. In conjunction with27* @{class:PhutilDirectoryKeyValueCache}, this gives us nice directories28* inside `.divinercache` instead of a million hash files with huge names at29* the top level.30*/31protected function getHashKey($hash) {32return implode(33'/',34array(35substr($hash, 0, 2),36substr($hash, 2, 2),37substr($hash, 4, 8),38));39}4041}424344