We are excited to announce a new Data Structure in the MemoryStore Service - the Hash Map. The Hash Map is a key-value store with no sorting guarantees, making it the ideal data structure for a simple high-throughput data cache. Use this to implement a shared inventory, live auction house, or to store player metadata for your experience (such as an active server list).
MemoryStore Hash Maps have no data structure item limits or data structure memory limits. You are free to store as many items as you want, so long as you do not reach the Universe memory size quota. It does, however, maintain the individual item size constraints (128 bytes for a key, 32 kilobytes for a value). Additionally, it provides the same basic functions as a Sorted Map - GetAsync(), RemoveAsync(), SetAsync(), UpdateAsync() - you can effectively hot swap a Sorted Map to a Hash Map if the ordering of items is not needed for your use case. If you are using the GetRangeAsync() function but not utilizing the ordering of items in your Sorted Map, you can replace it with a call to the Hash Map’s ListItemsAsync() function (this method lists items in a paginated fashion).
In addition to the Hash Map Data Structure, we have also decided to revamp the MemoryStore Rate Limits! We will be replacing the per-data structure request limit with a new per-partition limit. A partition is a subsection of storage in which MemoryStore data is cached. Data is distributed across these partitions differently by data structure type. This limit will be higher than the old per-data structure limit, providing extra flexibility in how you use the MemoryStore data structures. To minimize the chances of hitting the partition limit, see the updated Best Practices guide.
The API guide has been updated with details about this new data structure, including a section on Hash Maps and one on the new partition limits. We hope you find this useful!
As always, your feedback is invaluable for us to improve our services and fit your needs. Feel free to share any comments or questions below, and we’ll do our best to answer. We can’t wait to see what you build with this new feature!
The unlimited items and flexible memory limits will help us all to streamline data management.
The partition-based rate limits are a smart improvement, giving us more flexibility.
And the hot-swap feature and ListItemsAsync() function should prove to be very useful.
Loving the focus on allowing developers to streamline data management more!
What a great update!
Perfect timing! Almost coincidental… We were just about to release a global mutex lock system that implemented SortedMaps as a temporary implementation.
Not quite, data in a hash map still has to expire, and you are still held to the MemoryStore memory limit, which is much more limited than DatastoreService (which supports theoretically infinite storage space). Hash maps are more suited for temporary, small amounts of data that need to be read / written to very often.
I’m a little bit confused on what the ListItemsAsync() “count” parameter means by “max possible number of items returned”. Does this mean the max amount of pages returned, or the max amount of total entries within all of the pages it returns?
Good question, and apologies if the docs aren’t clear! This refers to the max number of entries on one page. So if your max is 50, each page would have up-to 50 items
Howdy. I may not use MemoryStore, this seems like a great update to it. Since it can be used for live auctions or shared inventory. Which seems like a easier way of getting a players data to other players. Without risking people finding weak points. I LIKE SHARDING. (Sharing data from any player with set conditions.)
I’m thinking Turn Based Games, more accurate abilities with stamina steal, etc. In Adventure games where you have a bag of items. You can drop it and it will track all what you had in it and other players can look in the bag.