Class
MemoryStoreHashMap
NotCreatableNotReplicated
Provides access to a hash map within MemoryStoreService.
Provides access to a hash map within MemoryStoreService. A hash map is
a collection of items where string keys are associated with arbitrary values
(up to the maximum allowed size -- see
Memory Stores). The keys
have no ordering guarantees.
Methods 5#
| GetAsync | Retrieves the value of a key in the hash map.Yields |
| ListItemsAsync | Returns a MemoryStoreHashMapPages object for enumerating through
items in the hash map.Yields |
| RemoveAsync | Removes an item from the hash map.Yields |
| SetAsync | Sets the value of a key in the hash map.Yields |
| UpdateAsync | Retrieves the value of a key from a hash map and lets you update it to a new value.Yields |
GetAsync(key: string): Variant#
Yields
Retrieves the value of a key in the hash map.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The key whose value you want to retrieve. |
Returns
Variant— The value, ornilif the key doesn't exist.
ListItemsAsync(count: int): MemoryStoreHashMapPages#
Yields
Returns a MemoryStoreHashMapPages object for enumerating through
items in the hash map. The valid range is 1 to 200 inclusive.
| Name | Type | Default | Description |
|---|---|---|---|
count | int | Maximum possible number of items that can be returned. |
Returns
MemoryStoreHashMapPages— AMemoryStoreHashMapPagesinstance that enumerates the items asMemoryStoreHashMapPagesinstances.
RemoveAsync(key: string): ()#
Yields
Removes an item from the hash map.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The key to remove. |
Returns
()
SetAsync(key: string, value: Variant, expiration: int64): boolean#
Yields
Sets the value of a key in the hash map, overwriting any existing value.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The key whose value to set. | |
value | Variant | The value to set. | |
expiration | int64 | 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
boolean—trueif the key already had a value that was overwritten, orfalseif the key was newly created.
UpdateAsync(key: string, transformFunction: Function, expiration: int64): Variant#
Yields
Retrieves the value of a key from a hash map and lets you update it to a new value.
This method accepts a callback function that retrieves the existing key value and passes it to a transform function, which returns the new value for the item, with these exceptions:
- If the key does not exist, the old value passed to the function is
nil. - If the function returns
nil, the update is canceled.
The new value is saved only if the key was not updated (for example, by a
different game server) since the moment it was read. If the value changed
in that time, the transform function is called again with the most recent
item value. This cycle repeats until the value is saved successfully or
the transform function returns nil to abort the operation.
| Name | Type | Default | Description |
|---|---|---|---|
key | string | The key whose value you want to update. | |
transformFunction | Function | The transform function, which you provide. This function takes the old value as an input and returns the new value. | |
expiration | int64 | 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
Variant— The last value returned by the transform function.
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild