Tries to acquire the lock for the specified key. When the lock is not available,

            * If timeout is not provided, the current thread doesn't wait and returns ``false`` immediately.
            * If a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies
              dormant until one of the followings happens:
                * the lock is acquired by the current thread, or
                * the specified waiting time elapses.

        If lease_time is provided, lock will be released after this time elapses.

        :param key: (object), key to lock in this map.
        :param lease_time: (int), time in seconds to wait before releasing the lock (optional).
        :param timeout: (int), maximum time in seconds to wait for the lock (optional).
        :return: (bool), ``true`` if the lock was acquired and otherwise, false.

def try_lock(self, key, lease_time=-1, timeout=-1):
        """
        Tries to acquire the lock for the specified key. When the lock is not available,

            * If timeout is not provided, the current thread doesn't wait and returns ``false`` immediately.
            * If a timeout is provided, the current thread becomes disabled for thread scheduling purposes and lies
              dormant until one of the followings happens:
                * the lock is acquired by the current thread, or
                * the specified waiting time elapses.

        If lease_time is provided, lock will be released after this time elapses.

        :param key: (object), key to lock in this map.
        :param lease_time: (int), time in seconds to wait before releasing the lock (optional).
        :param timeout: (int), maximum time in seconds to wait for the lock (optional).
        :return: (bool), ``true`` if the lock was acquired and otherwise, false.
        """
        check_not_none(key, "key can't be None")
        key_data = self._to_data(key)
        return self._encode_invoke_on_key(multi_map_try_lock_codec, key_data, key=key_data,
                                          thread_id=thread_id(), lease=to_millis(lease_time),
                                          timeout=to_millis(timeout),
                                          reference_id=self.reference_id_generator.get_and_increment())