Viewing version 2.20.1. Open the latest package page.

hive_ce

2.20.1

Hive Community Edition - A spiritual continuation of Hive v2

Download archive

Readme

Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask.

Documentation & Samples 📖

Features

  • 🚀 Cross platform: mobile, desktop, browser
  • ⚡ Great performance (see benchmark)
  • ❤️ Simple, powerful, & intuitive API
  • 🔒 Strong encryption built in
  • 🎈 NO native dependencies
  • 🔋 Batteries included

New features in Hive CE

Hive CE is a spiritual continuation of Hive v2 with the following new features:

  • Hive CE Inspector DevTools extension
    • Quickly and easily inspect the content of Hive boxes
  • Isolate support through IsolatedHive
  • Flutter web WASM support
  • Automatic type adapter generation using the GenerateAdapters annotation
    • No more manually adding annotations to every type and field
    • Generate adapters for classes outside the current package
  • A HiveRegistrar extension that lets you register all your generated adapters in one call
  • Extends the maximum type ID from 223 to 65439
  • Support for constructor parameter defaults
  • Support for Sets
  • A built in Duration adapter
  • Freezed support
  • Support for generating adapters with classes that use named imports

Benchmark

This is a comparison of the time to complete a given number of write operations and the resulting database file size:

Operations Hive CE Time IsolatedHive Time Hive CE Size Hive v4 Time Hive v4 Size
10 0.00 s 0.00 s 0.00 MB 0.00 s 1.00 MB
100 0.00 s 0.01 s 0.01 MB 0.01 s 1.00 MB
1000 0.02 s 0.03 s 0.11 MB 0.06 s 1.00 MB
10000 0.13 s 0.25 s 1.10 MB 0.64 s 5.00 MB
100000 1.40 s 2.64 s 10.97 MB 7.26 s 30.00 MB
1000000 19.94 s 41.50 s 109.67 MB 84.87 s 290.00 MB

Database size in Hive v4 is directly affected by the length of field names in model classes which is not ideal. Also Hive v4 is much slower than Hive CE for large numbers of operations.

IsolatedHive is slower than Hive, but it is much faster than Hive v4 and you still get the benefit of multiple isolate support.

The benchmark was performed on an M3 Max MacBook Pro. You can see the benchmark code here.

Getting Started

Hive CE requires Dart 3. Ensure that you have the following in your pubspec.yaml file:

environment:
  sdk: ^3.0.0

Usage

You can use Hive just like a map. It is not necessary to await Futures.

import 'package:hive_ce/hive_ce.dart';

void example() {
  final box = Hive.box('myBox');
  box.put('name', 'David');
  final name = box.get('name');
  print('Name: $name');
}

Changelog

2.20.1

  • Fixes a race where retrying a failed openBox could drop the in-flight open (by @LahaLuhem in #320)
  • Opening a box with the wrong cipher now throws instead of wiping the box during crash recovery (by @LahaLuhem in #330)

2.20.0

  • IsolatedHive compaction now uses IsolatedCompactionStrategy

2.19.3

  • IsolatedHive: Handles stale send ports on hot restart

2.19.2

  • Updates isolate_channel to 0.6.0

2.19.1

  • Updates isolate_channel to 0.4.0

2.19.0

2.18.0

  • Fixes an issue with IsolatedHive encryption
  • Automatically disables the unsafe isolate warning when running in a test

2.17.0

  • Fixes WASM int decoding (by @flrnsbt in #262)
  • Adds nested primitive support to CollectionBox
  • Adds more options to the logger to ignore specific warnings

2.16.0

  • Implements a proper logging system
  • Adds hive_ce.dart to make the publish action happy

2.15.1

2.15.0

  • Adds ignoredFields parameter to AdapterSpec for excluding specific fields from type adapter generation (by @rezam92 in #229)

2.14.0

  • Adds the ability to override type adapters by type (by @sportismygame in #217)
  • Fixes some Future handling issues

2.13.3

  • Adds copy to clipboard functionality to the inspector

2.13.2

  • Removes the print statement from the inspector

2.13.1

  • Fixes the first column header not showing in the inspector

2.13.0

  • Adds the Hive CE Inspector DevTools extension

2.12.0

  • Notify with the value of a deleted frame instead of null
  • Improves adapter of same type warning

2.11.4

  • Handles exception thrown during compaction on some platforms
  • Updates documentation for IsolatedHive

2.11.3

  • Prints warning when writing integers greater than 2^53

2.11.2

  • Fixes web compatibility check
  • Fixes deleteFromDisk not completing on web

2.11.1

  • Allows boxes of primitive iterables

2.11.0

  • Isolate support through IsolatedHive
  • Warning messages for potentially unsafe isolate usage
  • Updates suggested placement of GenerateAdapters annotation
  • Fixes custom objects in BoxCollection. Custom objects must now be json serializable.
  • Adds much more information to the unknown typeId error message
  • Supports freezed default values
  • Enforces that boxes of type Map must be Map<dynamic, dynamic>
  • Enforces that boxes of type Iterable must be Iterable<dynamic>
  • Adds reservedTypeIds to GenerateAdapters annotation

2.10.1

  • Fixes HiveObject disposal in lazy boxes

2.10.0

  • Raises the maximum type ID from 223 to 65439

2.9.0

  • Prints a warning when writing int or List<int> types in a WASM environment
  • Only emits print statements when assertions are enabled (aka debug mode)

2.8.0+3

  • Updates the commit hash for the transitive Hive dependencies workaround

2.8.0+2

  • Adds workaround for transitive Hive dependencies to README

2.8.0+1

  • Adds tutorial link to README

2.8.0

  • Adds GenerateAdapters annotation and relevant documentation

2.7.0+1

  • Adds a storage benchmark to compare Hive CE with Hive v4

2.7.0

  • No longer reinitializes Hive when opening a BoxCollection

2.6.0

  • Adds TargetKind.parameter to HiveField to support freezed

2.5.0+2

  • Adds documentation for adding new fields (@vizakenjack)
  • Updates README badges

2.5.0+1

  • Documentation updates for HiveField in support of hive_ce_generator changes

2.5.0

  • Adds Target annotations to HiveField and HiveType to prevent invalid usage
  • Bumps analyzer to ^6.5.0 to deal with deprecations
  • Bumps meta to ^1.14.0 for TargetKind.enumValue

2.4.4

  • Loosens constraint on web

2.4.3

  • Loosens constraint on meta

2.4.2

  • Only shows the adapter with same type warning if the adapters have different type ids

2.4.1

  • Upgrades package:web to 1.0.0

2.4.0+1

  • Adds a guide to migrate from hive
  • Adds documentation for the new HiveRegistrar extension created by hive_ce_generator

2.4.0

  • Adds support for Sets
  • Adds a built in DurationAdapter
  • Adds a warning if attempting to register multiple adapters for the same type

2.3.0

  • The first release of Hive Community Edition
  • Supports Flutter web WASM compilation
  • Fixes analysis issues

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'hive_ce:2.20.1'
pubspec.yaml
name: hive_ce
description: Hive Community Edition - A spiritual continuation of Hive v2
version: 2.20.1
homepage: https://github.com/IO-Design-Team/hive_ce/tree/main/hive

topics:
  - hive
  - database
  - nosql

funding:
  - https://github.com/sponsors/Rexios80

environment:
  sdk: ^3.4.0

dependencies:
  meta: ^1.14.0
  crypto: ^3.0.0
  web: ">=0.5.0 <2.0.0"
  isolate_channel: ^0.6.0
  json_annotation: ^4.9.0

dev_dependencies:
  test: ^1.17.12
  mocktail: ^1.0.4
  rexios_lints: ^19.0.0
  path: ^1.7.0
  pointycastle: ^4.0.0
  build_runner: ^2.5.4
  json_serializable: ^6.9.4

Version history

VersionPublishedArchiveSHA-256
2.3.0Cached · Upstream SHA-256 matchedDownload77c34007…19df6f
2.4.0Cached · Upstream SHA-256 matchedDownloadfd6b1b54…c8beb6
2.4.0+1Cached · Upstream SHA-256 matchedDownload6bdbb02a…e8b250
2.4.1Cached · Upstream SHA-256 matchedDownloadfa6e1afc…bf2863
2.4.2Cached · Upstream SHA-256 matchedDownload4e248199…5fe895
2.4.3Cached · Upstream SHA-256 matchedDownloadb6839a83…f9a9ca
2.4.4Cached · Upstream SHA-256 matchedDownloadf81eb3dc…0218b0
2.5.0Cached · Upstream SHA-256 matchedDownloadcfff1703…a80c14
2.5.0+1Cached · Upstream SHA-256 matchedDownloadf58c10f3…ec7e86
2.5.0+2Cached · Upstream SHA-256 matchedDownloadd706cd0b…623bf2
2.6.0Cached · Upstream SHA-256 matchedDownload8521ce23…6eac7a
2.7.0Cached · Upstream SHA-256 matchedDownload5ca75422…a18354
2.7.0+1Cached · Upstream SHA-256 matchedDownloadab1b79ce…cef65f
2.8.0Cached · Upstream SHA-256 matchedDownloadfd5f6648…3427ee
2.8.0+1Cached · Upstream SHA-256 matchedDownload9a2bc9c3…bd8ae5
2.8.0+2Cached · Upstream SHA-256 matchedDownload2d66fa89…532e99
2.8.0+3Cached · Upstream SHA-256 matchedDownloadf09558be…f94ffb
2.9.0Cached · Upstream SHA-256 matchedDownload918d3379…36a51b
2.10.0Cached · Upstream SHA-256 matchedDownload34ac3a77…c61390
2.10.1Cached · Upstream SHA-256 matchedDownloadac66daee…06647f
2.11.0-pre.1Cached · Upstream SHA-256 matchedDownloadfa90469a…04753f
2.11.0-pre.2Cached · Upstream SHA-256 matchedDownloadd5eb3de0…64dd6f
2.11.0-pre.3Cached · Upstream SHA-256 matchedDownloadd1494e80…40d352
2.11.0-pre.4Cached · Upstream SHA-256 matchedDownload35585368…bfe967
2.11.0-pre.5Cached · Upstream SHA-256 matchedDownloadfd7dc787…d6ba87
2.11.0-pre.6Cached · Upstream SHA-256 matchedDownloadff7b837b…908f62
2.11.0-pre.7Cached · Upstream SHA-256 matchedDownload0bdbfe95…bfabdd
2.11.0-pre.8Cached · Upstream SHA-256 matchedDownload2522c94f…7f1bc4
2.11.0-pre.9Cached · Upstream SHA-256 matchedDownloadc09ed51b…9b4114
2.11.0-pre.10Cached · Upstream SHA-256 matchedDownload68849dde…f5c863
2.11.0-pre.11Cached · Upstream SHA-256 matchedDownload819782d7…b62147
2.11.0Cached · Upstream SHA-256 matchedDownloadfb6560a9…4de82a
2.11.1Cached · Upstream SHA-256 matchedDownloadfdc19336…f2989e
2.11.2Cached · Upstream SHA-256 matchedDownload192b7334…3addc6
2.11.3Cached · Upstream SHA-256 matchedDownload708bb390…130658
2.11.4Cached · Upstream SHA-256 matchedDownload5620f634…bbfdd6
2.12.0Cached · Upstream SHA-256 matchedDownload74461ee8…02eb95
2.13.0-pre.1Cached · Upstream SHA-256 matchedDownloadfea389f5…311eb8
2.13.0-pre.2Cached · Upstream SHA-256 matchedDownload917325dd…668671
2.13.0Cached · Upstream SHA-256 matchedDownloadda9fa16e…f8d41e
2.13.1Cached · Upstream SHA-256 matchedDownload37be80cd…b4b1fe
2.13.2Cached · Upstream SHA-256 matchedDownload89746b55…ccb8a4
2.13.3Cached · Upstream SHA-256 matchedDownload040d58b4…63d3b8
2.14.0Cached · Upstream SHA-256 matchedDownloadd678b1b2…0c60aa
2.15.0Cached · Upstream SHA-256 matchedDownloade3a9d260…cb0847
2.15.1Cached · Upstream SHA-256 matchedDownload81d39a03…f0d230
2.16.0Cached · Upstream SHA-256 matchedDownload412c638a…184bed
2.17.0Cached · Upstream SHA-256 matchedDownload29f8791b…762664
2.18.0Cached · Upstream SHA-256 matchedDownloadb01cb16f…021516
2.19.0Cached · Upstream SHA-256 matchedDownloadcb4654bb…ae5cb6
2.19.1Cached · Upstream SHA-256 matchedDownloadb844955c…86bdb5
2.19.2Cached · Upstream SHA-256 matchedDownloadc3f6775d…e9f781
2.19.3Cached · Upstream SHA-256 matchedDownload8e9980e6…294418
2.20.0Cached · Upstream SHA-256 matchedDownload650b6428…1518e9
2.20.1Cached · Upstream SHA-256 matchedDownload2b1bf607…8909ce
2.20.2Cached · Upstream SHA-256 matchedDownload85d43209…427c87
2.21.0Cached · Upstream SHA-256 matchedDownload940042ee…03ac5d
2.22.0Cached · Upstream SHA-256 matchedDownload8b6eea82…81392a

Dependencies

crypto "^3.0.0"

isolate_channel "^0.6.0"

json_annotation "^4.9.0"

meta "^1.14.0"

web "\u003e=0.5.0 \u003c2.0.0"