local function lock_and_find (key, lock_id, lock_timeout) if is_locked_by_another_owner(key, lock_id) then return { "locked_by_other" } end local existing_entry = get_existing_entry(key) if not existing_entry then return { "not_found" } end local additional_keys = existing_entry.additional_lock_keys if is_any_locked_by_another_owner(additional_keys) then return { "locked_by_other" } end acquire_lock(key, lock_id, lock_timeout) acquire_locks(additional_keys, lock_id, lock_timeout) update_expire_at(key, existing_entry) return { "ok", existing_entry.value } end return scriptResult(lock_and_find(KEYS[1], ARGV[3], ARGV[4]))