コード例 #1
0
ファイル: Semaphore.php プロジェクト: shabbyrobe/cachet
 private function getId($cacheId, $key)
 {
     $id = $this->getLockKey($cacheId, $key);
     if (!is_int($id) || $id > PHP_INT_MAX || $id < ~PHP_INT_MAX) {
         $id = \Cachet\Helper::hashToInt32($id);
     }
     return $id;
 }
コード例 #2
0
ファイル: Sharding.php プロジェクト: shabbyrobe/cachet
 private function selectBackend($cacheId, $key)
 {
     $hashValue = "{$cacheId}/{$key}";
     $backendId = abs(\Cachet\Helper::hashToInt32($hashValue) % $this->backendCount);
     return $this->backends[$backendId];
 }
コード例 #3
0
ファイル: File.php プロジェクト: shabbyrobe/cachet
 private function createSafeKey($key)
 {
     $safeKey = substr(preg_replace("/[^a-z\\d_\\-]/", "", strtolower($key)), 0, 50);
     // crc32 is platform dependent? not that it should matter, but it makes testing
     // quite tricky.
     $hashedKey = base_convert(\Cachet\Helper::hashToInt32($key), 10, 36) . ($safeKey ? "-{$safeKey}" : '');
     return $hashedKey;
 }