public function haveInRedis($type, $key, $value)
    {
        switch (strtolower($type)) {
            case 'string':
                if (!is_scalar($value)) {
                    throw new ModuleException(
                        $this,
                        'If second argument of haveInRedis() method is "string", '
                        . 'third argument must be a scalar'
                    );
                }
                $this->driver->set($key, $value);
                break;

            case 'list':
                $this->driver->rpush($key, $value);
                break;

            case 'set':
                $this->driver->sadd($key, $value);
                break;

            case 'zset':
                if (!is_array($value)) {
                    throw new ModuleException(
                        $this,
                        'If second argument of haveInRedis() method is "zset", '
                        . 'third argument must be an (associative) array'
                    );
                }
                $this->driver->zadd($key, $value);
                break;

            case 'hash':
                if (!is_array($value)) {
                    throw new ModuleException(
                        $this,
                        'If second argument of haveInRedis() method is "hash", '
                        . 'third argument must be an array'
                    );
                }
                $this->driver->hmset($key, $value);
                break;

            default:
                throw new ModuleException(
                    $this,
                    "Unknown type \"$type\" for key \"$key\". Allowed types are "
                    . '"string", "list", "set", "zset", "hash"'
                );
        }
    }
public function haveInRedis($type, $key, $value)
    {
        switch (strtolower($type)) {
            case 'string':
                if (!is_scalar($value)) {
                    throw new ModuleException(
                        $this,
                        'If second argument of haveInRedis() method is "string", '
                        . 'third argument must be a scalar'
                    );
                }
                $this->driver->set($key, $value);
                break;

            case 'list':
                $this->driver->rpush($key, $value);
                break;

            case 'set':
                $this->driver->sadd($key, $value);
                break;

            case 'zset':
                if (!is_array($value)) {
                    throw new ModuleException(
                        $this,
                        'If second argument of haveInRedis() method is "zset", '
                        . 'third argument must be an (associative) array'
                    );
                }
                $this->driver->zadd($key, $value);
                break;

            case 'hash':
                if (!is_array($value)) {
                    throw new ModuleException(
                        $this,
                        'If second argument of haveInRedis() method is "hash", '
                        . 'third argument must be an array'
                    );
                }
                $this->driver->hmset($key, $value);
                break;

            default:
                throw new ModuleException(
                    $this,
                    "Unknown type \"$type\" for key \"$key\". Allowed types are "
                    . '"string", "list", "set", "zset", "hash"'
                );
        }
    }
public function haveInRedis ( $ type , $ key , $ value ) { switch ( strtolower ( $ type ) ) { case 'string' : if ( ! is_scalar ( $ value ) ) { throw new ModuleException ( $ this , 'If second argument of haveInRedis() method is "string", ' . 'third argument must be a scalar' ) ; } $ this -> driver -> set ( $ key , $ value ) ; break ; case 'list' : $ this -> driver -> rpush ( $ key , $ value ) ; break ; case 'set' : $ this -> driver -> sadd ( $ key , $ value ) ; break ; case 'zset' : if ( ! is_array ( $ value ) ) { throw new ModuleException ( $ this , 'If second argument of haveInRedis() method is "zset", ' . 'third argument must be an (associative) array' ) ; } $ this -> driver -> zadd ( $ key , $ value ) ; break ; case 'hash' : if ( ! is_array ( $ value ) ) { throw new ModuleException ( $ this , 'If second argument of haveInRedis() method is "hash", ' . 'third argument must be an array' ) ; } $ this -> driver -> hmset ( $ key , $ value ) ; break ; default : throw new ModuleException ( $ this , "Unknown type \"$type\" for key \"$key\". Allowed types are " . '"string", "list", "set", "zset", "hash"' ) ; } }
Creates or modifies keys

If $key already exists:

- Strings: its value will be overwritten with $value
- Other types: $value items will be appended to its value

Examples:

``` php
<?php
// Strings: $value must be a scalar
$I->haveInRedis('string', 'Obladi Oblada');

// Lists: $value can be a scalar or an array
$I->haveInRedis('list', ['riri', 'fifi', 'loulou']);

// Sets: $value can be a scalar or an array
$I->haveInRedis('set', ['riri', 'fifi', 'loulou']);

// ZSets: $value must be an associative array with scores
$I->haveInRedis('zset', ['riri' => 1, 'fifi' => 2, 'loulou' => 3]);

// Hashes: $value must be an associative array
$I->haveInRedis('hash', ['obladi' => 'oblada']);
```

@param string $type  The type of the key
@param string $key   The key name
@param mixed  $value The value

@throws ModuleException
Creates or modifies keys