搜索插件、代码仓与 APP 分类

插件详情v5.1.3

crdt

冲突自由复制数据类型(CRDT)的 Dart 实现。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2620
喜欢数
83
Pub 分数
150

安装插件

flutter pub add crdt

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一种冲突无害复制数据类型(CRDT)的Dart实现,可在分布式系统中实现一致且实时的协作,无需协调。即使在网络分区或并发更新的情况下,CRDT也能确保数据收敛,使其非常适合用于共享文档、实时仪表板和多人游戏等协作应用。该包支持多种平台,包括移动设备、Web和桌面端,确保跨平台一致性。

适合场景

  • 实时协同编辑
  • 分布式状态同步
  • 离线优先的应用程序
  • 多人游戏状态管理
  • 实时仪表板更新

主要特点

  • 无冲突的数据收敛
  • 对多种 CRDT 类型的支持
  • 跨平台兼容性
  • 低延迟更新
  • 无需中央协调

适合对象

  • 开发实时应用程序的开发者
  • 需要离线优先功能的团队
  • 具有分布式用户的应用程序
  • 需要强一致性的协作工具
  • 网络条件不可靠的系统

使用建议

  • 需要理解 CRDT 原理
  • 由于数据复制,可能会增加数据大小
  • 不适合高频原子操作
  • 限于特定数据结构
  • 性能取决于数据复杂度

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Dart implementation of Conflict-free Replicated Data Types (CRDTs).

This project is heavily influenced by James Long's talk CRTDs for Mortals and includes a Dart-native implementation of Hybrid Local Clocks (HLC) based on the paper Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases (pdf).

It has minimal external dependencies, so it should run anywhere where Dart runs, which is pretty much everywhere.

The Crdt class implements CRDT conflict resolution and serves as a storage-agnostic interface for specific implementations. Als included with this package is MapCrdt, an ephemeral implementation using Dart HashMaps.

Other implementations include (so far):

  • hive_crdt, a no-sql implementation using Hive as persistent storage.
  • sql_crdt, an abstract implementation for using relational databases as a data storage backend.
  • sqlite_crdt, an implementation using Sqlite for storage, useful for mobile or small projects.
  • postgres_crdt, a sql_crdt that benefits from PostgreSQL's performance and scalability intended for backend applications.

See also crdt_sync, a turnkey approach for real-time network synchronization of Crdt nodes.

Usage

The simplest way to experiment with this package is to use the provided MapCrdt implementation:

import 'package:crdt/map_crdt.dart';

void main() {
  var crdt1 = MapCrdt(['table']);
  var crdt2 = MapCrdt(['table']);

  print('Inserting 2 records in crdt1…');
  crdt1.put('table', 'a', 1);
  crdt1.put('table', 'b', 1);

  print('crdt1: ${crdt1.getMap('table')}');

  print('\nInserting a conflicting record in crdt2…');
  crdt2.put('table', 'a', 2);

  print('crdt2: ${crdt2.getMap('table')}');

  print('\nMerging crdt2 into crdt1…');
  crdt1.merge(crdt2.getChangeset());

  print('crdt1: ${crdt1.getMap('table')}');
}

Implementations

crdt is currently helping build local-first experiences for:

  • Libra a weigh management app with 1M+ installs.
  • tudo an open-source simple to-do app + backend.

Are you using this package in your project? Let me know!

Features and bugs

Please file feature requests and bugs at the issue tracker.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。