estimateSizeInBytes method

Future<int> estimateSizeInBytes()

获取缓存大小估算值(字节)

Implementation

Future<int> estimateSizeInBytes() async {
  final db = await _resolveDatabase();
  if (db == null) {
    return 0;
  }

  try {
    final records = await _store.find(db);
    int totalSize = 0;
    for (final record in records) {
      totalSize += record.key.length * 2;
      totalSize += record.value.toString().length * 2;
    }
    return totalSize;
  } catch (error, stacktrace) {
    LogUtil.v(
        'RxNetDataBase: estimateSizeInBytes error: $error\n$stacktrace');
    return 0;
  }
}