IMoBroPersistenceManager
The IMoBroPersistenceManager
provides a simple and efficient way for plugins to serialize and persist arbitrary
objects to disk.
Data is stored in the plugin's data directory and remains accessible between plugin starts.
note
Objects managed by this service are persisted in JSON format and therefore must be serializable using the
System.Text.Json.JsonSerializer
.
Functions
Put<T>(string, T)
Stores data with the specified key.
Type Parameters
Name | Description |
---|---|
T | The type of data to store |
Parameters
Name | Type | Description |
---|---|---|
key | string | The unique key to identify the data |
data | T | The data to be stored |
Get<T>(string): T?
Retrieves the data associated with the specified key.
Type Parameters
Name | Description |
---|---|
T | The type of data to retrieve |
Parameters
Name | Type | Description |
---|---|---|
key | string | The key to identify the stored data |
Returns
- The stored data of type
T
if it exists. default(T)
if the key is not found or the object is not of typeT
.
Remove(string): bool
Removes the data associated with the specified key.
Parameters
Name | Type | Description |
---|---|---|
key | string | The key to identify the data to remove |
Returns
true
: If the data was successfully removed.false
: If the key does not exist.
Exists(string): bool
Checks whether data associated with the specified key exists in the store.
Parameters
Name | Type | Description |
---|---|---|
key | string | The key to check for existence |
Returns
true
: If data with the specified key exists.false
: If data with the specified key does not exist.
Clear()
Deletes all persisted data.