パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v6.1.1+1

flutter_persistent_queue

Flutter用のシンプルなファイルベースの非揮発性永続キュー実装。アプリの実行間で保持される必要があるデバイス内の順次バッファに最適です。

30日間ダウンロード
121
いいね数
10
Pub ポイント
40

パッケージをインストール

flutter pub add flutter_persistent_queue

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Flutter向けのシンプルなファイルベースの永続キューで、データをデバイスに非揮発的に保存します。アプリ再起動後もデータの整合性と永続性を保証し、タスクキューまたはログのような順序バッファを維持するのに最適です。Dartで構築され、ローカルファイルストレージを使用して、アプリが終了したりデバイスが再起動してもアイテムを信頼性高く保持します。軽量で、信頼性の高いオフラインデータ処理が必要なアプリへの簡単な統合を目的としています。

用途

  • オフラインタスクキュー
  • 永続的ログ記録
  • 同期前のデータバッファリング
  • アプリ再起動のレジリエンス
  • ローカル状態の永続化
  • バックグラウンド操作ステージング

主な機能

  • ファイルベースのストレージ
  • 非揮発性の永続化
  • シンプルな API
  • アプリ間再起動耐久性
  • 順次的FIFO動作
  • 軽量な実装

適している対象

  • オフラインデータ保持を必要とするアプリ
  • タスク管理システム
  • ログフレームワーク
  • バックグラウンド処理ワークフロー
  • シンプルな状態付きコンポーネント
  • 低複雑性キューの必要性

注意事項

  • ファイルシステムストレージに限定
  • 組み込みの暗号化なし
  • 大規模なデータセットには適していません
  • 手動でのクリーンアップが必要になる場合があります
  • パフォーマンスはディスクI/Oに依存します
  • クラウド同期なし

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

persistent_queue

Simple file-based non-volatile queue library for flutter.

Typical use-case scenario is for small to medium sized in-device buffers storing persistent yet temporary mission-critical data, until it can be efficiently and safely consumed / delivered permanently - such as for custom analytics and specialized logging applications.

Installation

Add dependency to pubspec.yaml:

dependencies:
  ...
  flutter_persistent_queue: ^6.2.0

Run in your terminal:

flutter packages get

Example

import 'package:flutter_persistent_queue/flutter_persistent_queue.dart';

// instantiate a new queue `pq`, with auto-flush set at 10 items
final pq = PersistentQueue('pq', flushAt: 10, onFlush: (list) async {
  print('auto-flush\n$list');
});

// push 25 Map<<String, dynamic>> items (await is optional)
for (int i = 0; i < 25; ++i) {
  pq.push(<String, dynamic>{'i': i});
}

// trigger a final manual flush for the remaining items
pq.flush((list) async => print('manual-flush\n$list'));

// check if all items have been flushed
assert(await pq.futureLength == 0);

// deallocate resources, if needed
await pq.destroy();

Testing

For integration / performance tests:

git clone https://github.com/oakromulo/flutter_persistent_queue.git
cd ~/flutter_persistent_queue/test
flutter drive --target=test_driver/app.dart

Building documentation files

rm -rf doc
dartdoc --exclude 'dart:async,dart:collection,dart:convert,dart:core,dart:developer,dart:io,dart:isolate,dart:math,dart:typed_data,dart:ui'

How it works

Each JSON-encodable item when enqueued goes to its own indexed key in a single non-volatile file (one file per uniquely named queue) to an unspecified location on the permanent storage of a flutter-compatible device.

This particular design choice limits potential use cases requiring very long queues but otherwise provides good performance within a limited resource footprint, as it doesn't require serializing and deserializing contiguous or chunked dart:collections to the filesystem.

Every push() call triggers an asynchronous and isolated write to the permanent storage. If the caller awaits until its completion, it is notified via Completers and afterwards there's no possibility of data loss from the application perspective.

After user-defined flush() operations (either manual or auto-triggered) the queue is fully emptied if and only if the user-defined onFlush does not throw any errors.

All PersistentQueue methods are consumed sequentially (according to the strict chronological order of its calls) one at a time on a dedicated producer / consumer event loop.

Performance of persisted queues on standard simulated devices must be of at least 500 writes/second. This constraint is verified on integration tests.

All filesystem and JSON operations are abstracted by the minimalistic flutter_localstorage library.

License

MIT

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。