public function set($key, $value, $ttl = null)
    {
        if ($this->getCompress()) {
            $value = self::compress($value);
        }

        $keyP = $this->getPatternKey().$key;

        if (is_null($ttl)) {
            $func = function ($redis) use ($keyP, $value) {
                $start = microtime(true);
                $redis->set($keyP, $value);
                $this->notifyEvent('set', array($keyP, $value), microtime(true) - $start);

                return $redis;
            };
        } else {
            $func = function ($redis) use ($keyP, $value, $ttl) {
                $start = microtime(true);
                $redis->setex($keyP, $ttl, $value);
                $this->notifyEvent('setex', array($keyP, $ttl, $value), microtime(true) - $start);

                return $redis;
            };
        }

        if (true === $this->multi) {
            $this->addToExecList($key, $func);
        } else {
            $func($this->getRedis($key)); // set "normal"
        }

        return $this;
    }
public function set($key, $value, $ttl = null)
    {
        if ($this->getCompress()) {
            $value = self::compress($value);
        }

        $keyP = $this->getPatternKey().$key;

        if (is_null($ttl)) {
            $func = function ($redis) use ($keyP, $value) {
                $start = microtime(true);
                $redis->set($keyP, $value);
                $this->notifyEvent('set', array($keyP, $value), microtime(true) - $start);

                return $redis;
            };
        } else {
            $func = function ($redis) use ($keyP, $value, $ttl) {
                $start = microtime(true);
                $redis->setex($keyP, $ttl, $value);
                $this->notifyEvent('setex', array($keyP, $ttl, $value), microtime(true) - $start);

                return $redis;
            };
        }

        if (true === $this->multi) {
            $this->addToExecList($key, $func);
        } else {
            $func($this->getRedis($key)); // set "normal"
        }

        return $this;
    }
public function set ( $ key , $ value , $ ttl = null ) { if ( $ this -> getCompress ( ) ) { $ value = self :: compress ( $ value ) ; } $ keyP = $ this -> getPatternKey ( ) . $ key ; if ( is_null ( $ ttl ) ) { $ func = function ( $ redis ) use ( $ keyP , $ value ) { $ start = microtime ( true ) ; $ redis -> set ( $ keyP , $ value ) ; $ this -> notifyEvent ( 'set' , array ( $ keyP , $ value ) , microtime ( true ) - $ start ) ; return $ redis ; } ; } else { $ func = function ( $ redis ) use ( $ keyP , $ value , $ ttl ) { $ start = microtime ( true ) ; $ redis -> setex ( $ keyP , $ ttl , $ value ) ; $ this -> notifyEvent ( 'setex' , array ( $ keyP , $ ttl , $ value ) , microtime ( true ) - $ start ) ; return $ redis ; } ; } if ( true === $ this -> multi ) { $ this -> addToExecList ( $ key , $ func ) ; } else { $ func ( $ this -> getRedis ( $ key ) ) ; // set "normal" } return $ this ; }
set a value

@param string  $key   la clé
@param string  $value valeur
@param integer $ttl   time to live

@return Cache
set a value