> For the complete documentation index, see [llms.txt](https://docs.overdare.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overdare.com/development/api-reference/classes/memorystoreservice.md).

# MemoryStoreService

MemoryStoreService : `Instance`

## Overview

MemoryStoreService is a service that provides access to memory-based data stores that multiple servers in the same world read from and write to together. Use it for data that changes quickly and frequently, such as matchmaking queues, real-time leaderboards, and state shared across servers.

Three types of stores are provided: HashMap (key-value), SortedMap (sorted key-value), and Queue (priority queue). Each is retrieved by name through the GetHashMap(), GetSortedMap(), and GetQueue() methods, respectively. A store does not need to be created separately; it is created at the time of the first write.

This service can only be used in server Scripts, and calling it from a LocalScript raises an error.

**Important Notes**

* Because the storage is volatile, data may be lost when the storage restarts. Use DataStoreService for data that must not be lost.
* Methods that read and write values in a store do not use caching so that the latest state is shared across servers, and they send a new request on every call.
* In Studio, it runs as a local in-memory emulation. Data is lost when Play stops, and concurrent access contention between multiple servers and request and capacity limits are not reproduced. Contention between scripts (coroutines) within the same server is reproduced, so it is recommended to verify live server behavior again in a deployed environment.

## Properties

## Methods

### GetHashMap

Returns the MemoryStoreHashMap with the specified name.

This method returns immediately without sending a network request. Calling it again with the same name returns the same object.

The name is not validated by this method; it is validated the first time data is read or written through the returned object. Reading a store where nothing has been saved yet returns an empty result without an error.

#### Parameters

| `string` InName | <p>The name of the HashMap to retrieve.</p><ul><li>Must be 1 to 128 characters long, and an empty name or a name consisting only of whitespace raises an error on the first data access.</li></ul> |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

#### Return

| `MemoryStoreHashMap` | A MemoryStoreHashMap object that accesses the store with the specified name. |
| -------------------- | ---------------------------------------------------------------------------- |

#### Code Samples

### GetQueue

Returns the MemoryStoreQueue with the specified name and invisibility timeout (InvisibilityTimeout).

This method returns immediately without sending a network request. If both the name and the invisibility timeout are the same, it returns the same object. If the name is the same but the invisibility timeout differs, it returns a different object that operates with its own invisibility timeout.

The name and invisibility timeout are not validated by this method; they are validated the first time data is read or written through the returned object.

#### Parameters

| `string` InName                | <p>The name of the Queue to retrieve.</p><ul><li>Must be 1 to 128 characters long, and an empty name or a name consisting only of whitespace raises an error on the first data access.</li></ul>                                                                                                                                                   |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `number` InInvisibilityTimeout | <p>(Optional) The time (in seconds) during which items read by ReadAsync are hidden from other reads.</p><ul><li>If omitted, it is 30 seconds.</li><li>Specifying 0 does not hide items that have been read.</li><li>A value outside the range of 0 to 2,147,483.647 seconds (about 24.9 days) raises an error when ReadAsync is called.</li></ul> |

#### Return

| `MemoryStoreQueue` | A MemoryStoreQueue object that operates with the specified name and invisibility timeout. |
| ------------------ | ----------------------------------------------------------------------------------------- |

#### Code Samples

### GetSortedMap

Returns the MemoryStoreSortedMap with the specified name.

This method returns immediately without sending a network request. Calling it again with the same name returns the same object.

The name is not validated by this method; it is validated the first time data is read or written through the returned object.

#### Parameters

| `string` InName | <p>The name of the SortedMap to retrieve.</p><ul><li>Must be 1 to 128 characters long, and an empty name or a name consisting only of whitespace raises an error on the first data access.</li></ul> |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

#### Return

| `MemoryStoreSortedMap` | A MemoryStoreSortedMap object that accesses the store with the specified name. |
| ---------------------- | ------------------------------------------------------------------------------ |

#### Code Samples

## Events
