library/Rediska/Command/CompareSets.php
public function create(array $keys, $storeKey = null)
    {
        if (empty($keys)) {
            throw new Rediska_Command_Exception('You must specify sets');
        }

        $connections = array();
        $keysByConnections = array();
        foreach ($keys as $key) {
            $connection = $this->_rediska->getConnectionByKeyName($key);
            $connectionAlias = $connection->getAlias();
            if (!array_key_exists($connectionAlias, $connections)) {
                $connections[$connectionAlias] = $connection;
                $keysByConnections[$connectionAlias] = array();
            }
            $keysByConnections[$connectionAlias][] = $key;
        }

        if (count($connections) == 1) {
            $connectionValues = array_values($connections);
            $connection = $connectionValues[0];

            if (!is_null($storeKey)) {
                $storeConnection = $this->_rediska->getConnectionByKeyName($storeKey);
                if ($storeConnection === $connection) {
                    $command = array($this->_storeCommand,
                                     $this->_rediska->getOption('namespace') . $storeKey);
                } else {
                    $this->setAtomic(false);
                    $this->_storeConnection = $storeConnection;
                    $command = array($this->_command);
                }
            } else {
                $command = array($this->_command);
            }

            $connectionKeys = array_keys($connections);
            $connectionAlias = $connectionKeys[0];

            foreach($keysByConnections[$connectionAlias] as $key) {
                $command[] = $this->_rediska->getOption('namespace') . $key;
            }

            return new Rediska_Connection_Exec($connection, $command);
        } else {
            $this->setAtomic(false);

            $commands = array();
            foreach($keysByConnections as $connectionAlias => $keys) {
                foreach ($keys as $key) {
                    $command = array('SMEMBERS',
                                     $this->_rediska->getOption('namespace') . $key);
                    $commands[] = new Rediska_Connection_Exec($connections[$connectionAlias], $command);
                }
            }

            return $commands;
        }
    }
public function create(array $keys, $storeKey = null)
    {
        if (empty($keys)) {
            throw new Rediska_Command_Exception('You must specify sets');
        }

        $connections = array();
        $keysByConnections = array();
        foreach ($keys as $key) {
            $connection = $this->_rediska->getConnectionByKeyName($key);
            $connectionAlias = $connection->getAlias();
            if (!array_key_exists($connectionAlias, $connections)) {
                $connections[$connectionAlias] = $connection;
                $keysByConnections[$connectionAlias] = array();
            }
            $keysByConnections[$connectionAlias][] = $key;
        }

        if (count($connections) == 1) {
            $connectionValues = array_values($connections);
            $connection = $connectionValues[0];

            if (!is_null($storeKey)) {
                $storeConnection = $this->_rediska->getConnectionByKeyName($storeKey);
                if ($storeConnection === $connection) {
                    $command = array($this->_storeCommand,
                                     $this->_rediska->getOption('namespace') . $storeKey);
                } else {
                    $this->setAtomic(false);
                    $this->_storeConnection = $storeConnection;
                    $command = array($this->_command);
                }
            } else {
                $command = array($this->_command);
            }

            $connectionKeys = array_keys($connections);
            $connectionAlias = $connectionKeys[0];

            foreach($keysByConnections[$connectionAlias] as $key) {
                $command[] = $this->_rediska->getOption('namespace') . $key;
            }

            return new Rediska_Connection_Exec($connection, $command);
        } else {
            $this->setAtomic(false);

            $commands = array();
            foreach($keysByConnections as $connectionAlias => $keys) {
                foreach ($keys as $key) {
                    $command = array('SMEMBERS',
                                     $this->_rediska->getOption('namespace') . $key);
                    $commands[] = new Rediska_Connection_Exec($connections[$connectionAlias], $command);
                }
            }

            return $commands;
        }
    }
Create command

@param array            $keys     Array of key names
@param string[optional] $storeKey Store to set with key name
@return Rediska_Connection_Exec