Quick function to extract the expiration time from options. Throws
    appropriate exceptions when necessary
    :param key_options:
    :param global_options:
    :return:

def get_ttl(key_options, global_options, *_):
    """
    Quick function to extract the expiration time from options. Throws
    appropriate exceptions when necessary
    :param key_options:
    :param global_options:
    :return:
    """
    ttl = get_option('ttl', key_options, global_options)
    if ttl is None or ttl == 0:
        return 0

    try:
        ttl = int(ttl)
        if ttl < 0:
            raise ArgumentError.pyexc("TTL cannot be negative", obj=ttl)
        elif ttl > 1 << 31:
            raise ArgumentError.pyexc("TTL Value too large", obj=ttl)
        return ttl
    except CouchbaseError:
        raise
    except Exception as e:
        raise ArgumentError.pyexc(inner=e, obj=ttl)