Exemple #1
0
 /**
  *
  *
  * @param $Key
  * @param int $Flags
  * @return array|bool
  * @throws Exception
  */
 protected function _getKeyPath($Key, $Flags = 0)
 {
     $KeyHash = $this->_HashKey($Key);
     $SplitValue = intval('0x' . substr($KeyHash, 0, 8), 16);
     $TargetFolder = (string) ($SplitValue % Gdn_Filecache::OPT_MOD_SPLIT);
     $Container = $this->_getContainer($KeyHash);
     if ($Container === Gdn_Cache::CACHEOP_FAILURE) {
         return $this->failure("Trying to fetch a container for hash '{$KeyHash}' but got back CACHEOP_FAILURE instead");
     }
     $CacheLocation = $Container[Gdn_Cache::CONTAINER_LOCATION];
     $SplitCacheLocation = CombinePaths(array($CacheLocation, $TargetFolder));
     $Flags = $Flags & Gdn_Filecache::O_CREATE ? Gdn_FileSystem::O_CREATE | Gdn_FileSystem::O_WRITE : 0;
     $CacheLocationOK = Gdn_FileSystem::checkFolderR($SplitCacheLocation, $Flags);
     if (!$CacheLocationOK && $Flags & Gdn_Filecache::O_CREATE) {
         return $this->failure("Computed cache folder '{$SplitCacheLocation}' could not be found, or created.");
     }
     $CacheFile = rtrim(CombinePaths(array($SplitCacheLocation, $KeyHash)), '/');
     return array_merge($Container, array(Gdn_Filecache::CONTAINER_CACHEFILE => $CacheFile));
 }