소스 검색

Add an abstraction for a virtual command that leverages Redis scripting with the new EVAL command.

Daniele Alessandri 14 년 전
부모
커밋
2bdfed5071
1개의 변경된 파일16개의 추가작업 그리고 0개의 파일을 삭제
  1. 16 0
      lib/Predis/Commands/ScriptedCommand.php

+ 16 - 0
lib/Predis/Commands/ScriptedCommand.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace Predis\Commands;
+
+abstract class ScriptedCommand extends ServerEval {
+    public abstract function getScript();
+
+    public abstract function keysCount();
+
+    protected function filterArguments(Array $arguments) {
+        if (($keys = $this->keysCount()) === -1) {
+            $keys = count($arguments);
+        }
+        return array_merge(array($this->getScript(), $keys), $arguments);
+    }
+}