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

패키지 상세v2.21.7

firestore_cache

캐시에서 먼저 읽은 후 서버에서 Firestore 문서를 가져오는 Flutter 플러그인

AndroidiOSWebmacOSWindows
30일 다운로드
3.3천
좋아요
107
Pub 점수
160

패키지 설치

flutter pub add firestore_cache

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

firestore_cache는 캐시 우선 전략으로 Firestore 문서를 가져오는 데 도움을 주는 Flutter 패키지입니다. 이는 서버와의 동기화를 선택적으로 수행하면서도 빠른 로컬 응답을 보장합니다. 즉각적인 표시를 위해 캐시된 데이터를 우선 처리하고, 서버에서 비동기로 캐시를 업데이트함으로써 네트워크 지연 또는 오프라인 상황에서도 앱 성능과 사용자 경험을 향상시킵니다. 이 패키지는 Android, iOS, Web, macOS, Windows 등 모든 주요 플랫폼을 지원하며, 반응성 있는 데이터 접근과 백업 신뢰성을 필요로 하는 애플리케이션에 이상적입니다.

사용 사례

  • 오프라인 우선 데이터 검색
  • 빠른 초기 UI 렌더링
  • Firestore와의 백그라운드 동기화
  • 개선된 앱 반응성
  • 무결점 네트워크 복구

주요 기능

  • 캐시 우선 문서 가져오기
  • 자동 서버 동기화
  • 크로스 플랫폼 지원
  • 간단한 API 통합
  • 실시간 데이터 일관성

적합한 대상

  • 빠른 로컬 데이터 접근이 필요한 앱
  • 오프라인 기능을 구현하는 개발자
  • Firebase Firestore를 사용하는 프로젝트
  • 즉각적인 피드백이 필요한 UI
  • 신뢰할 수 없는 네트워크 연결을 가진 애플리케이션

고려 사항

  • 시작 시 오래된 데이터를 제공할 수 있습니다
  • 캐시 무효화에 주의 깊게 대응해야 합니다
  • 실시간 핵심 업데이트에 적합하지 않습니다
  • Firestore 문서 읽기로 제한
  • 네트워크 사용량은 동기화 빈도에 따라 달라집니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Firestore Cache

pub package docs MIT License GitHub Actions codecov Codacy Badge style: flutter_lints

Github-sponsors BuyMeACoffee Ko-Fi LiberaPay Patreon PayPal

A Flutter plugin for fetching Firestore documents with read from cache first then server.

This plugin is mainly designed for applications using the DocumentReference.get() and Query.get() methods in the cloud_firestore plugin, and is implemented with read from cache first then server.

Getting Started

Add this to your package's pubspec.yaml file:

dependencies:
  firestore_cache: ^2.21.2
Usage

Before using the plugin, you will need to create a document on Firestore and create a timestamp field in that document. See the screenshot below for an example:

Firestore Screenshot

⚠️ PLEASE NOTE This plugin does not compare the documents in the cache and the ones in the server to determine if it should fetch data from the server. Instead, it relies on the timestamp field in the document to make that decision. And so your application should implement the logic to update this field if you want to read new data from the server instead of reading it from the cache.

You should also create different timestamp fields for different collections or documents that you are fetching.

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firestore_cache/firestore_cache.dart';

// This should be the path of the document containing the timestamp field
// that you created
final cacheDocRef = Firestore.instance.doc('status/status');

// This should be the timestamp field in that document
final cacheField = 'updatedAt';

final query = Firestore.instance.collection('posts');
final snapshot = await FirestoreCache.getDocuments(
    query: query,
    cacheDocRef: cacheDocRef,
    firestoreCacheField: cacheField,
);

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

아직 데이터가 없습니다.