public function set($key, $value, $ttl = null)
    {
        $this->ensureValidKey($key);
        if ($ttl !== null) {
            $restore = $this->innerEngine->getConfig('duration');
            $this->innerEngine->setConfig('duration', $ttl);
        }
        try {
            $result = $this->innerEngine->write($key, $value);

            return (bool)$result;
        } finally {
            if (isset($restore)) {
                $this->innerEngine->setConfig('duration', $restore);
            }
        }
    }
public function set($key, $value, $ttl = null)
    {
        $this->ensureValidKey($key);
        if ($ttl !== null) {
            $restore = $this->innerEngine->getConfig('duration');
            $this->innerEngine->setConfig('duration', $ttl);
        }
        try {
            $result = $this->innerEngine->write($key, $value);

            return (bool)$result;
        } finally {
            if (isset($restore)) {
                $this->innerEngine->setConfig('duration', $restore);
            }
        }
    }
public function set ( $ key , $ value , $ ttl = null ) { $ this -> ensureValidKey ( $ key ) ; if ( $ ttl !== null ) { $ restore = $ this -> innerEngine -> getConfig ( 'duration' ) ; $ this -> innerEngine -> setConfig ( 'duration' , $ ttl ) ; } try { $ result = $ this -> innerEngine -> write ( $ key , $ value ) ; return ( bool ) $ result ; } finally { if ( isset ( $ restore ) ) { $ this -> innerEngine -> setConfig ( 'duration' , $ restore ) ; } } }
Persists data in the cache, uniquely referenced by the given key with an optional expiration TTL time.

@param string $key The key of the item to store.
@param mixed $value The value of the item to store, must be serializable.
@param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
the driver supports TTL then the library may set a default value
for it or let the driver take care of that.
@return bool True on success and false on failure.
@throws \Cake\Cache\InvalidArgumentException
MUST be thrown if the $key string is not a legal value.
Persists data in the cache uniquely referenced by the given key with an optional expiration TTL time .