public function lock () {
        if (!$this->beforeLock ()) {
            return false;
        }
        $redis = $this->getConnection ()->getClient ();
        if (!$redis->setnx ($this->name , $this->getExpiresAt (true))) {
            // see if this mutex has expired

            $value = $redis->get ($this->name);
            if ($value > microtime (true)) {
                return false;
            }
        }
        $this->afterLock ();
        return true;
    }