패키지, 저장소 및 앱 카테고리 검색

패키지 상세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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.