Constructor
new DataStorage(key, gameDataStorage)
定义一个DataStorage
| Name | Type | Description |
|---|---|---|
key | string | 空间名称(只读) |
gameDataStorage | GameDataStorage | 对应的 |
- Source
Members
key :string
数据储存空间名称
- string
- Source
key :string
数据储存空间名称
- string
- Source
Methods
(async) get(key) → {ReturnValue|undefined}
获取指定键对应的值
如果没有指定的键,返回undefined
注意:非Pro地图version将会返回空字符串
| Name | Type | Description |
|---|---|---|
key | string | 指定的键 |
- Source
- Type:
- ReturnValue |
undefined
(async) set(key, value)
传入指定键与值,无论该键是否存在,均将值设置到此键上。
| Name | Type | Description |
|---|---|---|
key | string | 需要设置的键 |
value | JSONValue | 需要设置的值 |
- Source
(async) update(key, handler)
使用传入的方法更新键值对
| Name | Type | Description |
|---|---|---|
key | string | 需要更新的键 |
handler | dataStorageUpdateCallBack | 处理更新的方法,接受一个参数,为当前键的值,返回一个更新后的值 |
- Source
(async) list(options) → {QueryList|Array.<ReturnValue>}
批量获取键值对注意:该方法不会创建缓存和读取缓存,所以比 目前在完全缓存的情况下可以在此使用缓存,需要更改配置文件get更慢
| Name | Type | Description |
|---|---|---|
options | ListPageOptions | 批量获取键值对的配置项 |
- Source
- Type:
- QueryList |
Array.<ReturnValue>
(async) remove(key)
删除键值对
| Name | Type | Description |
|---|---|---|
key | string | 需要删除的键 |
- Source
(async) drop()
删除表格
警告:删除之后无法恢复,请谨慎使用!!!
- Source
(async) createCache()
创建数据储存空间缓存
会缓存全部数据
对于有大量数据的数据库来说,不建议这么做,因为会消耗大量内存
- Source
(async) get(key) → {ReturnValue|undefined}
获取指定键对应的值
如果没有指定的键,返回undefined
注意:非Pro地图version将会返回空字符串
| Name | Type | Description |
|---|---|---|
key | string | 指定的键 |
- Source
- Type:
- ReturnValue |
undefined
(async) set(key, value)
传入指定键与值,无论该键是否存在,均将值设置到此键上。
| Name | Type | Description |
|---|---|---|
key | string | 需要设置的键 |
value | JSONValue | 需要设置的值 |
- Source
(async) update(key, handler)
使用传入的方法更新键值对
| Name | Type | Description |
|---|---|---|
key | string | 需要更新的键 |
handler | dataStorageUpdateCallBack | 处理更新的方法,接受一个参数,为当前键的值,返回一个更新后的值 |
- Source
(async) list(options) → {QueryList|Array.<ReturnValue>}
批量获取键值对注意:该方法不会创建缓存和读取缓存,所以比 目前在完全缓存的情况下可以在此使用缓存,需要更改配置文件get更慢
| Name | Type | Description |
|---|---|---|
options | ListPageOptions | 批量获取键值对的配置项 |
- Source
- Type:
- QueryList |
Array.<ReturnValue>
(async) remove(key)
删除键值对
| Name | Type | Description |
|---|---|---|
key | string | 需要删除的键 |
- Source
(async) drop()
删除表格
警告:删除之后无法恢复,请谨慎使用!!!
- Source
(async) createCache()
创建数据储存空间缓存
会缓存全部数据
对于有大量数据的数据库来说,不建议这么做,因为会消耗大量内存
- Source