Group Related Function Caching

Did Roblox recently make player:GetRoleInGroup() cache on the server side? I noticed some weird behavior in my game and I suspect that’s the cause.

If that is the case, we need to have a way to get an uncached indication of a player’s rank and role in a group. I’ve already made some pretty hacky code to get around player:GetRankInGroup() being cached, I don’t want to have to pass instructions to a client and have to trust their response for rank verification.

There are several group-related web endpoints listed here. They won’t cache, but you will need to use a proxy to access them via HttpService.

That’s another “hacky” solution that I’d prefer to avoid.

1 Like

You should do a test to see if this caches.

If it does, you should then test if GroupService:GetGroupsAsync caches.

If both cache then you’re going to have to use a proxy like @sircfenner suggested.

What exactly is caching, why is it bad and how do we check if something caches?

This is the definition of caching:
image
As you can see, it means to store away for future use. For example, if I use player:GetRankInGroup(), the data that it returns will be saved internally. When I call this again even after the rank has changed in the group, it will still return the OLD value.

This is bad for many developers because some projects rely on up-to-date data to make a seamless experience while playing a game. For example, checking ownership of assets used to be a pain because all of the checking methods cached (PlayerHasAsset and the new gamepass checking methods don’t do this, which is good, but it used to be really annoying). Even after the user bought the asset, it would still say they didn’t own it if they were previously in that server at all.

To check if something caches, call it once, change the thing it should return (group rank, for example), and call it again. If it still has the same value as before, it caches. If it shows the correct value, it doesn’t.

2 Likes

GetGroupsAsync doesn’t cache by the way, I use it in many projects to get an accurate role number for users in my group.

8 Likes

I’ll have to start using that, it seems like the solution I was looking for. Hopefully they don’t make this cache too.

Pretty sure anything with “Async” doesn’t cache.

“Async” in general programming refers to whether the function yields the thread it is called from. If I were to perform the equivalent of a dataStore save in JavaScript (as an example), the code after the dataStore save will run before the save is completed. I’m not entirely sure if Roblox is even using the term correctly, or just as a general indicator that the function can take a varying amount of time to complete.

I don’t see a logical correlation with Async functions and caching however.

1 Like

Okay, small update here.

I can understand caching :GetRoleInGroup and :GetRankInGroup on the server, but on the client too? Really?

I am curious as to whether or not the caching behaviour changed recently, I’ve had a few complaints from people within my group saying they their ranks were not updating immediately (it took several attempts of rejoining before it was updated), whereas before there were no issues.

I’ll use GetGroupsAsync now, but it’d be nice to know.

All group-related information functions cache now, even on the client. (Aside from any asynchronous functions.)
*As far as I can tell

Alright thanks, I’m pretty sure the behaviour has changed because it didn’t used to cache on the server as far as I could tell. I was able to update people’s ranks without them having to rejoin, at least there’s another solution.

I know for a fact that :GetRoleInGroup() didn’t cache, I used it for a ton of things.