# MemoryStoreQueue

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Not replicated
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/MemoryStoreQueue/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/MemoryStoreQueue

Provides access to a queue within MemoryStore.

## Methods

### AddAsync

```luau
MemoryStoreQueue:AddAsync(value: any, expiration: number, priority: number? = 0)
```

- Tags: Yields, Capabilities: DataStore

Adds an item to the queue.

Parameters:

- `value`: The value of the item to add to the queue.
- `expiration`: Item expiration time, in seconds, after which the item will be automatically removed from the queue.
- `priority`: Item priority. Items with higher priority are retrieved from the queue before items with lower priority.

### GetSizeAsync

```luau
MemoryStoreQueue:GetSizeAsync(excludeInvisible: boolean? = false): number
```

- Tags: Yields, Capabilities: DataStore

Gets the size of the queue.

Parameters:

- `excludeInvisible`: Determines whether to exclude invisible items from the size count.

Returns: The number of items currently in the queue. Items that have been read but not yet removed (invisible items) are included in the count unless `excludeInvisible` is `true`.

### ReadAsync

```luau
MemoryStoreQueue:ReadAsync(count: number, allOrNothing: boolean? = false, waitTimeout: number? = -1): ...any
```

- Tags: Yields, Capabilities: DataStore

Reads one or more items from the queue.

Parameters:

- `count`: Number of items to read. The maximum allowed value of this parameter is 100.
- `allOrNothing`: Controls the behavior of the method in the case the queue has fewer than `count` items: if set to false the method returns all available items; if set to true, it returns no items. The default value is false.
- `waitTimeout`: The duration, in seconds, for which the method will wait if the required number of items is not immediately available in the queue. Reads are attempted every two seconds during this period. This parameter can be set to zero to indicate no wait. If this parameter is not provided or set to -1, the method will wait indefinitely.

Returns: A tuple of two elements. The first element is an array of item values read from the queue. The second element is a string identifier that should be passed to [`MemoryStoreQueue:RemoveAsync()`](https://rapi.sleaze.dev/classes/MemoryStoreQueue.md) to permanently remove these items from the queue.

### RemoveAsync

```luau
MemoryStoreQueue:RemoveAsync(id: string)
```

- Tags: Yields, Capabilities: DataStore

Removes an item or items previously read from the queue.

Parameters:

- `id`: Identifies the items to delete. Use the value returned by [`MemoryStoreQueue:ReadAsync()`](https://rapi.sleaze.dev/classes/MemoryStoreQueue.md).

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
