public function set($key, $value, $ttl)
    {
        $this->initializeOnDemand();

        if (!is_string($key)) {
            throw new InvalidArgumentException(sprintf('Argument #1 must be a string and only, received "%s"', gettype($key)));
        }

        $time = time();

        if ($this->has($key)) {
            $this->cacheMapper->update($key, $value, $ttl);
        } else {
            $this->cacheMapper->insert($key, $value, $ttl, $time);
        }

        // For the current request
        $this->cache[$key] = array(
            ConstProviderInterface::CACHE_PARAM_VALUE => $value,
            ConstProviderInterface::CACHE_PARAM_CREATED_ON => $time,
            ConstProviderInterface::CACHE_PARAM_TTL => $ttl
        );

        return true;
    }
public function set($key, $value, $ttl)
    {
        $this->initializeOnDemand();

        if (!is_string($key)) {
            throw new InvalidArgumentException(sprintf('Argument #1 must be a string and only, received "%s"', gettype($key)));
        }

        $time = time();

        if ($this->has($key)) {
            $this->cacheMapper->update($key, $value, $ttl);
        } else {
            $this->cacheMapper->insert($key, $value, $ttl, $time);
        }

        // For the current request
        $this->cache[$key] = array(
            ConstProviderInterface::CACHE_PARAM_VALUE => $value,
            ConstProviderInterface::CACHE_PARAM_CREATED_ON => $time,
            ConstProviderInterface::CACHE_PARAM_TTL => $ttl
        );

        return true;
    }
public function set ( $ key , $ value , $ ttl ) { $ this -> initializeOnDemand ( ) ; if ( ! is_string ( $ key ) ) { throw new InvalidArgumentException ( sprintf ( 'Argument #1 must be a string and only, received "%s"' , gettype ( $ key ) ) ) ; } $ time = time ( ) ; if ( $ this -> has ( $ key ) ) { $ this -> cacheMapper -> update ( $ key , $ value , $ ttl ) ; } else { $ this -> cacheMapper -> insert ( $ key , $ value , $ ttl , $ time ) ; } // For the current request $ this -> cache [ $ key ] = array ( ConstProviderInterface :: CACHE_PARAM_VALUE => $ value , ConstProviderInterface :: CACHE_PARAM_CREATED_ON => $ time , ConstProviderInterface :: CACHE_PARAM_TTL => $ ttl ) ; return true ; }
Write data to the cache

@param string $key
@param mixed $value
@param integer $ttl The lifetime in seconds
@return boolean
Write data to the cache