Class · inherits Instance
MemoryStoreSortedMap
Provides access to a sorted map within MemoryStoreService.
About MemoryStoreSortedMap
Provides access to a sorted map within MemoryStoreService. A sorted
map is a collection of items where string keys are associated with arbitrary
values (up to the maximum allowed size -- see
Memory Stores). Each
item can also have an optional sort key, which can be a number or a string. In
the ordering of items, the sort key, if provided, takes precedence over the
key. Items with numeric sort keys are sorted before items with string sort
keys, which are sorted before items with no sort key. Items with the same sort
key and items with no sort key are arranged in alphabetical order by key.
Methods 6
GetAsync
(key: string) → TupleYieldsRetrieves the value and sort key of a key in the sorted map.GetRangeAsync
(direction: SortDirection, count: int, exclusiveLowerBound: Variant, exclusiveUpperBound: Variant) → ArrayYieldsRetrieves items within a sorted range of keys and sort keys.Gets items within a sorted range of keys and sort keys.
GetSizeAsync
() → intYieldsGets the size of the sorted map.RemoveAsync
(key: string) → ()YieldsRemoves the provided key from the sorted map.SetAsync
(key: string, value: Variant, expiration: int64, sortKey: Variant) → booleanYieldsSets the value of a key.Sets the value and sort key of the key overwriting any existing key value and sort key.
UpdateAsync
(key: string, transformFunction: Function, expiration: int64) → TupleYieldsRetrieves the value and sort key of a key from a sorted map and updates it with a new value and sort key.Retrieves the value and sort key of a key from a sorted map and lets you update it to a new value and sort key via a callback function.
This method accepts a callback function that transforms the old value and old sort key into the updated value and updated sort key as required. The method retrieves the existing key value and sort key and passes it to the transform function which returns the new value and sort key for the item, with these exceptions:
- If the key does not exist, the old value and old sort key passed to the
function will be
nil. - If the function returns
nil, the update is canceled.
The new value and new sort key is saved only if the key was not updated (e.g. by a different game server) since the moment it was read. If the value or sort key did change, the transform function is invoked again with the most recent item value and sort key. This cycle repeats until the value and sort key are saved successfully or the transform function returns
nilto abort the operation.- If the key does not exist, the old value and old sort key passed to the
function will be
MemoryStoreSortedMap also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.