# MemoryStoreHashMap

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/MemoryStoreHashMap/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/MemoryStoreHashMap

Provides access to a hash map within [`MemoryStoreService`](https://rapi.sleaze.dev/classes/MemoryStoreService.md).

## Methods

### GetAsync

```luau
MemoryStoreHashMap:GetAsync(key: string): any
```

- Tags: Yields, Capabilities: DataStore

Retrieves the value of a key in the hash map.

Parameters:

- `key`: The key whose value you want to retrieve.

Returns: The value, or `nil` if the key doesn't exist.

### ListItemsAsync

```luau
MemoryStoreHashMap:ListItemsAsync(count: number): MemoryStoreHashMapPages
```

- Tags: Yields, Capabilities: DataStore

Returns a [`MemoryStoreHashMapPages`](https://rapi.sleaze.dev/classes/MemoryStoreHashMapPages.md) object for enumerating through items in the hash map.

Parameters:

- `count`: Maximum possible number of items that can be returned.

Returns: A [`MemoryStoreHashMapPages`](https://rapi.sleaze.dev/classes/MemoryStoreHashMapPages.md) instance that enumerates the items as [`MemoryStoreHashMapPages`](https://rapi.sleaze.dev/classes/MemoryStoreHashMapPages.md) instances.

### RemoveAsync

```luau
MemoryStoreHashMap:RemoveAsync(key: string)
```

- Tags: Yields, Capabilities: DataStore

Removes an item from the hash map.

Parameters:

- `key`: The key to remove.

### SetAsync

```luau
MemoryStoreHashMap:SetAsync(key: string, value: any, expiration: number): boolean
```

- Tags: Yields, Capabilities: DataStore

Sets the value of a key in the hash map.

Parameters:

- `key`: The key whose value to set.
- `value`: The value to set.
- `expiration`: Item expiration in seconds, after which the item is automatically removed from the hash map. The maximum expiration time is 45 days (3,888,000 seconds).

Returns: `true` if the key already had a value that was overwritten, or `false` if the key was newly created.

### UpdateAsync

```luau
MemoryStoreHashMap:UpdateAsync(key: string, transformFunction: (...any) -> ...any, expiration: number): any
```

- Tags: Yields, Capabilities: DataStore

Retrieves the value of a key from a hash map and lets you update it to a new value.

Parameters:

- `key`: The key whose value you want to update.
- `transformFunction`: The transform function, which you provide. This function takes the old value as an input and returns the new value.
- `expiration`: Item expiration in seconds, after which the item is automatically removed from the hash map. The maximum expiration time is 45 days (3,888,000 seconds).

Returns: The last value returned by the transform function.

## 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`
