소스 검색

Added support for key tags: instead of hashing the full key, we hash only the portion enclosed within curly brackets.

Daniele Alessandri 15 년 전
부모
커밋
20e416306c
1개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 9 1
      lib/Predis.php

+ 9 - 1
lib/Predis.php

@@ -337,7 +337,15 @@ abstract class Command {
         }
         else {
             if (isset($this->_arguments[0])) {
-                $this->_hash = crc32($this->_arguments[0]);
+                $key = $this->_arguments[0];
+
+                $start = strpos($key, '{');
+                $end   = strpos($key, '}');
+                if ($start !== false && $end !== false) {
+                    $key = substr($key, ++$start, $end - $start);
+                }
+
+                $this->_hash = crc32($key);
                 return $this->_hash;
             }
         }