ZEPETO.Multiplay.DataStorage
Type | Description |
|---|---|
The error code specifies the reason for the failure of data storage-related requests. | |
DataStorage | Represents a data storage abstraction providing methods to store, retrieve, and remove data. This interface defines asynchronous operations for single and multiple data manipulations. |
DataStorageError
enum
The error code specifies the reason for the failure of data storage-related requests.
Name | Value | Description |
|---|---|---|
Unknown | -1 | Error: Unknown error. |
NetworkError | 0 | Error: Errors related to network issues, including disconnections or unstable connections. |
KeyConstraintViolated | 103 | Error: Key error. |
ValueConstraintViolated | 104 | Error: Value error. |
DataStorage
interface
Represents a data storage abstraction providing methods to store, retrieve, and remove data. This interface defines asynchronous operations for single and multiple data manipulations.
Methods
set
set(key: string, value: T) → Promise<boolean>
Stores a value with a specified key. Throws DataStorageError.
Parameter | Type | Description |
|---|---|---|
key | string | The key for storage. |
value | T | Data to store. |
Returns: Promise<boolean> — Promise resolved upon completion, indicating success (true) or failure (false).
get
get(key: string) → Promise<T>
Retrieves a value by its key. Throws DataStorageError.
Parameter | Type | Description |
|---|---|---|
key | string | The key to search for. |
Returns: Promise<T> — Promise resolved upon completion with a value of type T.
remove
remove(key: string) → Promise<boolean>
Removes a value with a specified key. Throws DataStorageError.
Parameter | Type | Description |
|---|---|---|
key | string | The key to search for. |
Returns: Promise<boolean> — Promise resolved upon completion, indicating success (true) or failure (false).
mget
mget(keys: string[]) → Promise<{ [key: string]: T }>
Retrieves values by multiple keys. Throws DataStorageError.
Parameter | Type | Description |
|---|---|---|
keys | string[] | Array of keys to search for. |
Returns: Promise<{ [key: string]: T }> — Promise resolved upon completion with a key-value object.
mset
mset(keyValueSet: { key: string; value: T }[]) → Promise<boolean>
Stores multiple values with specified keys. Throws DataStorageError.
Parameter | Type | Description |
|---|---|---|
keyValueSet | { key: string; value: T }[] | Array of key-value objects to store. |
Returns: Promise<boolean> — Promise resolved upon completion, indicating success (true) or failure (false).