RxNetDataBase class

author: ZhengZaiHong email:1096877329@qq.com date: 2023/9/9 time: 12:41 describe: 数据缓存 全平台支持(包括 Web 和 HarmonyOS) 纯 Dart 实现的 NoSQL 数据库,支持所有平台:

  • Android/iOS: 使用文件系统
  • Windows/Linux/macOS: 使用文件系统
  • Web: 使用 IndexedDB
  • HarmonyOS: 使用文件系统(纯 Dart 实现)

Constructors

RxNetDataBase()

Properties

hashCode int
The hash code for this object.
no setterinherited
isDatabaseReady bool
getter/setter pair
ready Future<void>
等待数据库初始化完成
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clean() Future<void>
清空所有数据
cleanMetadata() Future<void>
清空所有缓存条目元数据
clearByPattern(RegExp pattern) Future<int>
按正则模式清理缓存
clearByPrefix(String prefix) Future<int>
按前缀清理缓存
closeInstance() Future<void>
关闭当前实例的数据库连接
count() Future<int>
获取数据库中的记录数量
delete(String key) Future<void>
删除指定键的数据
deleteMetadata(String key) Future<void>
删除缓存条目元数据
estimateSizeInBytes() Future<int>
获取缓存大小估算值(字节)
exists(String key) Future<bool>
检查键是否存在
get<T>(dynamic key) Future<T?>
获取数据
getAllKeys() Future<List<String>>
获取所有键
getAllMetadata() Future<List<MapEntry<String, Map<String, dynamic>>>>
读取所有缓存条目元数据
getMetadata(String key) Future<Map<String, dynamic>?>
读取缓存条目元数据
init({String databaseName = 'rxnet_cache.db', String? cacheName = 'network_cache', String? databasePath}) Future<void>
初始化数据库(实例方法,支持多实例独立配置)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(dynamic key, dynamic value) Future
存储数据
putMetadata(String key, Map<String, dynamic> metadata) Future<void>
写入缓存条目元数据(用于淘汰策略)
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](dynamic key) Future
操作符重载:读取数据
operator []=(dynamic key, dynamic value) → void
操作符重载:写入数据

Static Properties

isReady bool
获取默认实例的数据库就绪状态(静态方法,向后兼容)
no setter

Static Methods

close() Future<void>
关闭数据库连接(静态方法,向后兼容)
initDatabase({String databaseName = 'rxnet_cache.db', String? cacheName = 'network_cache', String? databasePath}) Future<void>
初始化数据库(静态方法,向后兼容单例模式)
waitUntilReady() Future<void>
等待数据库初始化完成(静态方法,向后兼容)