Переглянути джерело

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;
             }
         }