What is MemoryStore?

Hello everybody! So, I’ve been trying to understand what is MemoryStore for a while now, but I failed every time. I can’t understand what is this queue thing. It’d be really helpful if any of you could kindly explain it to me. Thanks!

A similar service to DataStores. It’s a lot faster, but the data you store isn’t persistent, so it’ll get erased after a given amount of time with a hard coded max lifetime.

It makes storing temporary server data such as player lists a lot easier as it can automatically erase data of crashed servers if they don’t update the data within a specified delay.

4 Likes

I have heard that it can do some sort of matchmaking system, is it true?

Something like Rust? (If you’ve ever played/seen it.)

It can be used for that purpose, which the player list I mentioned is actually a part of.

Memory stores can be used for the dynamic portion. Store static data such as buildings and player inventory in data stores. Player counts, player lists and other stuff that doesn’t have to be kept after the server shuts down in memory stores

1 Like

So, in easy words it’s like your data per server. But the server is temporary, am I right? (Please correct me if I’m wrong)

Is basically a place to store temporary data between servers. I think you could in theory use it for cross server communication e.g. Match making or even maybe cross server trading or chat. You can probably connect all your running servers via this.

To add to this it also offers builtin queues which could offer extra functionality that datastores can’t.

2 Likes

Yep, unless you want to also have persistent server like Rust, but that adds another layer of complexity.

1 Like

So, now that I’m all clear about the basic of it, I’ve a question. How can I use GetQueue, AddAsync, RemoveAsync and ReadAsync? (from the MemoryStoreQueue)

Yes, but we already have MessagingService | Roblox Creator Documentation for cross-server communication. Using MemoryStoreService | Roblox Creator Documentation for this would be far less efficient.

2 Likes

messaging service isn’t very reliable, sorry for bumping

Yes, but MessagingService is meant for handling cross-server communication while MemoryStoreService is meant for sharing temporary data between them. I see what you mean, but now that I’ve had time to use both, I would personally rely primarily on MessagingService but use MemoryStoreService as a backup in case a signal fails to fire or something.

It’s more useful to use MemoryStoreService for saving the temporary data and MessagingService for signaling an action and saying that the data is there.

4 Likes

You could have the message service communicate each server to choose certain instances saved in MemoryStore, have them each update their share by reconstructing that portion of the MemoryStore, and essentially make the servers keep it persistent!

To persist a dead game as the bottom line, you would keep it on server storage first, then

while #game:GetPlayers()  ~= 0 do
------- persist in MemoryStore
while #game:GetPlayers() == 0 do
‐------ persist in ServerStorage
end

Wouldn’t it be easier to use data store for this though?

It’d be more of a lengthy process if you use Data stores. Like, DataStoreService:GetDataStore(...) and then

-- bla bla bla

and then

DataStore:RemoveAsync(...)

It’s way more of a lengthy process but if you use MemoryStore it’s better, efficient and faster for temporary data, like Rust server list.

But if we do it right, you can connect every server in the world in a new an innovative way! And when Roblox makes place teleporting seamless, we’ll probably be server hopping instantly, for sure!

Are you talking about storing data long term or temporarily?

In short, you could say I’m talking about both. Like server lists. Let’s say you only want to show a server when its owner is in it. Otherwise, it’ll not show up on the list. But, since it’s not possible for people to permanently stay in game, players will leave some time or another. But after all, it’s a temporary data.

1 Like