public function grabFromRedis($key)
    {
        $args = func_get_args();

        switch ($this->driver->type($key)) {
            case 'none':
                throw new ModuleException(
                    $this,
                    "Cannot grab key \"$key\" as it does not exist"
                );
                break;

            case 'string':
                $reply = $this->driver->get($key);
                break;

            case 'list':
                if (count($args) === 2) {
                    $reply = $this->driver->lindex($key, $args[1]);
                } else {
                    $reply = $this->driver->lrange(
                        $key,
                        isset($args[1]) ? $args[1] : 0,
                        isset($args[2]) ? $args[2] : -1
                    );
                }
                break;

            case 'set':
                $reply = $this->driver->smembers($key);
                break;

            case 'zset':
                if (count($args) === 2) {
                    throw new ModuleException(
                        $this,
                        "The method grabFromRedis(), when used with sorted "
                        . "sets, expects either one argument or three"
                    );
                }
                $reply = $this->driver->zrange(
                    $key,
                    isset($args[2]) ? $args[1] : 0,
                    isset($args[2]) ? $args[2] : -1,
                    'WITHSCORES'
                );
                break;

            case 'hash':
                $reply = isset($args[1])
                    ? $this->driver->hget($key, $args[1])
                    : $this->driver->hgetall($key);
                break;

            default:
                $reply = null;
        }

        return $reply;
    }
public function grabFromRedis($key)
    {
        $args = func_get_args();

        switch ($this->driver->type($key)) {
            case 'none':
                throw new ModuleException(
                    $this,
                    "Cannot grab key \"$key\" as it does not exist"
                );
                break;

            case 'string':
                $reply = $this->driver->get($key);
                break;

            case 'list':
                if (count($args) === 2) {
                    $reply = $this->driver->lindex($key, $args[1]);
                } else {
                    $reply = $this->driver->lrange(
                        $key,
                        isset($args[1]) ? $args[1] : 0,
                        isset($args[2]) ? $args[2] : -1
                    );
                }
                break;

            case 'set':
                $reply = $this->driver->smembers($key);
                break;

            case 'zset':
                if (count($args) === 2) {
                    throw new ModuleException(
                        $this,
                        "The method grabFromRedis(), when used with sorted "
                        . "sets, expects either one argument or three"
                    );
                }
                $reply = $this->driver->zrange(
                    $key,
                    isset($args[2]) ? $args[1] : 0,
                    isset($args[2]) ? $args[2] : -1,
                    'WITHSCORES'
                );
                break;

            case 'hash':
                $reply = isset($args[1])
                    ? $this->driver->hget($key, $args[1])
                    : $this->driver->hgetall($key);
                break;

            default:
                $reply = null;
        }

        return $reply;
    }
public function grabFromRedis ( $ key ) { $ args = func_get_args ( ) ; switch ( $ this -> driver -> type ( $ key ) ) { case 'none' : throw new ModuleException ( $ this , "Cannot grab key \"$key\" as it does not exist" ) ; break ; case 'string' : $ reply = $ this -> driver -> get ( $ key ) ; break ; case 'list' : if ( count ( $ args ) === 2 ) { $ reply = $ this -> driver -> lindex ( $ key , $ args [ 1 ] ) ; } else { $ reply = $ this -> driver -> lrange ( $ key , isset ( $ args [ 1 ] ) ? $ args [ 1 ] : 0 , isset ( $ args [ 2 ] ) ? $ args [ 2 ] : - 1 ) ; } break ; case 'set' : $ reply = $ this -> driver -> smembers ( $ key ) ; break ; case 'zset' : if ( count ( $ args ) === 2 ) { throw new ModuleException ( $ this , "The method grabFromRedis(), when used with sorted " . "sets, expects either one argument or three" ) ; } $ reply = $ this -> driver -> zrange ( $ key , isset ( $ args [ 2 ] ) ? $ args [ 1 ] : 0 , isset ( $ args [ 2 ] ) ? $ args [ 2 ] : - 1 , 'WITHSCORES' ) ; break ; case 'hash' : $ reply = isset ( $ args [ 1 ] ) ? $ this -> driver -> hget ( $ key , $ args [ 1 ] ) : $ this -> driver -> hgetall ( $ key ) ; break ; default : $ reply = null ; } return $ reply ; }
Returns the value of a given key

Examples:

``` php
<?php
// Strings
$I->grabFromRedis('string');

// Lists: get all members
$I->grabFromRedis('example:list');

// Lists: get a specific member
$I->grabFromRedis('example:list', 2);

// Lists: get a range of elements
$I->grabFromRedis('example:list', 2, 4);

// Sets: get all members
$I->grabFromRedis('example:set');

// ZSets: get all members
$I->grabFromRedis('example:zset');

// ZSets: get a range of members
$I->grabFromRedis('example:zset', 3, 12);

// Hashes: get all fields of a key
$I->grabFromRedis('example:hash');

// Hashes: get a specific field of a key
$I->grabFromRedis('example:hash', 'foo');
```

@param string $key The key name

@return mixed

@throws ModuleException if the key does not exist
Returns the value of a given key