[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diviner/cache/ -> DivinerDiskCache.php (source)

   1  <?php
   2  
   3  abstract class DivinerDiskCache {
   4  
   5    private $cache;
   6  
   7    public function __construct($cache_directory, $name) {
   8      $dir_cache = id(new PhutilDirectoryKeyValueCache())
   9        ->setCacheDirectory($cache_directory);
  10      $profiled_cache = id(new PhutilKeyValueCacheProfiler($dir_cache))
  11        ->setProfiler(PhutilServiceProfiler::getInstance())
  12        ->setName($name);
  13      $this->cache = $profiled_cache;
  14    }
  15  
  16    protected function getCache() {
  17      return $this->cache;
  18    }
  19  
  20    public function delete() {
  21      $this->getCache()->destroyCache();
  22      return $this;
  23    }
  24  
  25    /**
  26     * Convert a long-form hash key like `ccbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaN` into
  27     * a shortened directory form, like `cc/bb/aaaaaaaaN`. In conjunction with
  28     * @{class:PhutilDirectoryKeyValueCache}, this gives us nice directories
  29     * inside .divinercache instead of a million hash files with huge names at
  30     * top level.
  31     */
  32    protected function getHashKey($hash) {
  33      return implode(
  34        '/',
  35        array(
  36          substr($hash, 0, 2),
  37          substr($hash, 2, 2),
  38          substr($hash, 4, 8),
  39        ));
  40    }
  41  
  42  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1