Help with GetAsync

How can I get the number of GetAsyncs found in my DataStore? Lets say I stored 3 with the following keys:

  • “HELLO”
  • “WORLD”
  • “HELLO”

How would I find how many have the key “HELLO” or how many it finds with that specific key?

This seems like a simple problem, but it can actually be highly technical when dealing with databases and managing rate limiting. It would be very important to understand the usecase before designing a system.

Generally though, you could have another datastore key that keeps count of individual keys. As I mentioned though, this can run into problems and is not likely to be the efficient way of achieving your goals.

I just want it to return how many in my DataStore have that key, surely it can return a number right?

Like a for i = 0 loop?

It’s likely that you want to save all of this information in a single datastore entry, and not split up into a bunch of individual keys. You can make a new entry that keeps count but you are very likely going to get rate limited as you add and subtract from it.

In a datastore, the “Key” is like an index. It is unique. I assume you’ve meant the value. If you really do mean the “Key” then there can only ever be 1 or 0 since keys are unique.

So for example lets say I stored something with key “John Doe”, I can’t store another one with the key “John Doe”?

Yes-ish. If you try writing a datastore entry with the key “John Doe”, this will just overwrite any previous value that is saved with that key.

Any previous value for “John Doe” will be replaced with the new value for “John Doe”