Horde_HashTable_Base::set PHP Method

set() public method

Set the value of a key.
public set ( string $key, string $val, array $opts = [] ) : boolean
$key string The key.
$val string The string to store.
$opts array Additional options:
  - expire: (integer) Expiration time in seconds.
            DEFAULT: Doesn't expire.
  - replace: (boolean) Replace the value of key. If key doesn't exist,
             returns false.
             DEFAULT: false
return boolean True on success, false on error.
    public function set($key, $val, array $opts = array())
    {
        if (!empty($opts['replace']) && isset($this->_noexist[$key])) {
            return false;
        }
        /* @todo BC: 'timeout' == 'expire' usage. */
        if (isset($opts['timeout']) && !isset($opts['expire'])) {
            $opts['expire'] = $opts['timeout'];
        }
        if ($this->_set($this->hkey($key), $val, $opts)) {
            unset($this->_noexist[$key]);
            $res = true;
        } else {
            $res = false;
        }
        if (!empty($this->_params['logger'])) {
            $this->_params['logger']->debug(sprintf('%s: Set key %s(%s)', get_class($this), $res ? '' : 'FAILED ', $key));
        }
        return $res;
    }