hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
124 lines (57 loc) • 2.09 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [PersistenceManager](./server.persistencemanager.md)
## PersistenceManager class
Manages persistence of player and global data.
When to use: reading or writing persisted data shared across lobbies or per player. Do NOT use for: per-tick state; cache data in memory and write back periodically.
**Signature:**
```typescript
export default class PersistenceManager
```
## Remarks
This class is a singleton accessible with `PersistenceManager.instance`<!-- -->. Convenience methods are also available on `Player` and `GameServer`<!-- -->.
Pattern: load data on join, update in memory, and save on significant events. Anti-pattern: calling persistence APIs every frame.
\*\*Category:\*\* Persistence
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `PersistenceManager` class.
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[instance](./server.persistencemanager.instance.md)
</td><td>
`static`
`readonly`
</td><td>
[PersistenceManager](./server.persistencemanager.md)
</td><td>
Singleton instance.
\*\*Category:\*\* Persistence
</td></tr>
</tbody></table>
## Methods
<table><thead><tr><th>
Method
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[getGlobalData(key, maxRetries)](./server.persistencemanager.getglobaldata.md)
</td><td>
</td><td>
Get global data from the data persistence service.
</td></tr>
<tr><td>
[setGlobalData(key, data)](./server.persistencemanager.setglobaldata.md)
</td><td>
</td><td>
Set global data in the data persistence service. This data is available and shared by all lobbies of your game.
</td></tr>
</tbody></table>