Add a built in way to clear a memory store sorted map

Currently, to remove all keys from a memory store sorted map, you must list all the keys, then remove them one by one. This takes a pretty massive toll on the rate limit since the budgeting change making GetRangeAsync take as many units as returned. This means that to clear a sorted map of n length, you must use n*2 of your rate limit. This is because you must first list them, which takes n, then remove them one by one, which is another n.

This can be quite problematic for clearing when all your memory. I propose an api which would either take a single unit, or at the very least just n rather than n*2. Such a method would also make developing with memory stores easier as you don’t need a 20 line method that should be able to just be done in one line.

The format I’d like to see would be:

SortedMap:Clear()

Though I’d welcome anything. I’m fine with this taking n requests as well, but seeing as how unallocating all the memory inside shouldn’t actually be any issue, I don’t see why it would even need to take 1. But n is much better than n*2, which I’d be fine with as well.

Not only am I requesting this for rate limit reasons, but also just ease of development.

7 Likes

Roblox has an entire article on them:

I recommend you read these if you want to know what a memory store is.

Hey, thanks for the feedback. Could you explain more of your use case to clear the memory? Do you need it as part of your script or some UI / Open Cloud API would work for you?

I think (not sure) Steven need it for his matchmaking module to delete every game/queue with one call instead of calling RemoveAsync() for each key

Yes what @fouroul94 said is correct. I would like to clear the memory without having to fetch every key which takes a lot of queries which eats into the quota. Other use cases could be clearing the memory to change how things are stored in memory so that when you read them it doesn’t error out for missing data it’s expecting. But other than that I think it’s just useful to have a way to clear the memory easily.

Hi, bumping because I would also love to see this.

We’re using Sorted Maps for a global messaging system. Clearing the chat for moderation purposes will be a very expensive process rate-limit wise, as OP talked about. A method to bulk-delete keys or clear the Sorted Map entirely would be very useful.