Beispiel #1
0
 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;
 }
Beispiel #2
0
 private function selectBackend($cacheId, $key)
 {
     $hashValue = "{$cacheId}/{$key}";
     $backendId = abs(\Cachet\Helper::hashToInt32($hashValue) % $this->backendCount);
     return $this->backends[$backendId];
 }
Beispiel #3
0
 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;
 }