# LIFO

LIFO stands for Last-In-First-Out. This mode is the oposite of a standard queue, where jobs are processed in the same order as they arrive to the queue. In a LIFO queue the last added job will be processed before existing jobs.

To enable this mode for a given job just pass the "lifo" property and set it to true.

```typescript
interface JobOpts {
  lifo: boolean;
  // ... More opts
}
```

{% tabs %}
{% tab title="Curl" %}

```powershell
curl --location 'http://mydomain.dev/queues/my-queue/jobs' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer my-secret-token' \
--data '[{
	  "name": "paint-black",
          "data": {},
         },
         {
	  "name": "paint-red",
          "data": {},
          "opts": {
            "lifo": true
          }
         } 
]'
```

{% endtab %}
{% endtabs %}

In the above snippet, the job named "paint-red" will be processed before "paint-black" as it was added with the lifo option set to true.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bullmq.net/http-api/queues/adding-jobs/lifo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
