Skip to content

LLOR3NZ-RBX/MemoryStoreDistributedSortedMap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

MemoryStoreDistributedSortedMap

Creator Store: [Link]

An implementation of a Distributed Memory Store Sorted Map. I made this as a scalable alternative to the default Memory Store Sorted Map, allowing creators to define the number of "partitions". Each partition, under the hood, is actually its own sorted map, but the module orchestrates it so they act as a single map.

Interface

To use a Distributed Sorted Map:

  1. Import the module with
local MemoryStoreDistributedSortedMap = require(<path to script>.MemoryStoreDistributedSortedMap)
  1. Create a map with
MemoryStoreDistributedSortedMap(name: string, numPartitions: number?)
Parameter Description
name: string The name of the sorted map.
numPartitions: number? The number of the partitions to create in the sorted map. If not provided, defaults to 16.

After getting a Distributed Sorted Map, the method interface is completely backwards compatible with a regular Memory Store Sorted Map - see API. This module adds extra functionality to a single method - GetSizeAsync.

MemoryStoreDistributedSortedMap:GetSizeAsync(approximate: boolean?, numPartitionsToApproximate: number?)
Parameter Description
approximate: string? If the size should be approximated. If false or not provided, it will not approximate, and will scan all partitions.
numPartitionsToApproximate: number? The number of the partitions to sample, if approximate is true. If not provided, defaults to 1.

Example:

local MemoryStoreDistributedSortedMap = require(game.ServerScriptService.MemoryStoreDistributedSortedMap)

local map = MemoryStoreDistributedSortedMap("myMap", 100)
map:SetAsync("exp", 5, 300)
print(map:GetAsync("exp"))

Limits

Limit Type Limit
# Items ~ numPartitions * 100000
Size ~ numPartitions * 100 kb

Request Units

Function Request Unit(s)
GetAsync() 1
GetRangeAsync() <numPartitions * count
GetSizeAsync() numPartitionsToApproximate or numPartitions
RemoveAsync() 1
SetAsync() 1
UpdateAsync() >2

Acknowledgements

About

Roblox Memory Store Distributed Map. This is a personal project, not affiliated with Roblox.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages