juice_storage 2.2.0
juice_storage: ^2.2.0 copied to clipboard
Local storage, caching, and secure storage for the Juice framework. Supports Hive CE, SharedPreferences, SQLite, and flutter_secure_storage.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
2.2.0 - 2026-09-02 #
Added #
HiveGatewayseam (init/isAdapterRegistered/registerAdapter/openBox) withHiveGatewayImplas the shipped default, injected throughStorageBloc's factory exactly likeCacheIndex.InitializeUseCase's hive leg now runs entirely over the seam, so Hive's static init surface is no longer untestable. The gateway is an internal adapter (not exported); the factory parameter exists for test injection.
Fixed #
- Stale-lock cold boot no longer kills the session silently. A process
killed mid-write can leave a Hive box lock that fails exactly one boot. The
old catch put the whole session on a dead cache with no log line saying why
(observed 2026-09-01: every prefs read throwing
CacheIndex not initialized). Hive init now gets ONE bounded retry after 300ms, and a final failure is loud: logged throughJuiceLoggerConfig.logErroras well as the state'sStorageError(backendNotAvailable). Exactly two attempts, never more.
Tests #
- Three pins on the retry: clean init is one call with no noise; one transient
failure heals on the single retry (ready, boxes open,
retrying oncelogged, no error); persistent failure is loud and bounded (error state +StorageError+DEAD this sessionlogged, exactly two attempts).
2.1.0 - 2026-08-13 #
Changed #
- Updated the core dependency to
juice: ^1.6.0. - Every use-case builder now declares
EventConcurrency.concurrentexplicitly. Mutations enter a bloc-wide FIFO and preserve send order across different mutation event types; read-only queries remain genuinely concurrent. TTL reads join the FIFO only when performing lazy eviction. close()now waits for queued storage mutations before closing the cache index.
Tests #
- Added gated coverage for an overlapping TTL write and delete, proving the delete cannot overtake the write and leave stale expiration metadata.
- Added gated coverage proving independent reads can overlap.
2.0.0 - 2026-06-16 #
Changed (BREAKING) #
- Migrated from Hive to Hive CE (
hive_ce/hive_ce_flutter) — the originalhiveis unmaintained;hive_ceis its maintained, drop-in community continuation (same Hive v2 box/adapter API, on-disk format unchanged, so existing boxes keep working). Internally a pure import swap (no codegen change). Breaking only at the type boundary:StorageConfig.hiveAdaptersisList<TypeAdapter>andTypeAdapternow comes fromhive_ce, so apps registering custom adapters must importpackage:hive_ce/hive.dartinstead ofpackage:hive/hive.dart(no logic changes). Apps that don't usehiveAdapters(the common case) need only the dependency bump.
1.2.0 - 2026-04-18 #
Changed #
- Updated core dependency to
juice: ^1.4.0 - Refreshed README messaging around lifecycle-aware persistence and cache cleanup
1.1.0 - 2026-02-13 #
Added #
hiveKeyshelper method -StorageBloc.hiveKeys(box)returns all keys from a Hive boxHiveKeysEvent/HiveKeysUseCase- Event-driven Hive key enumeration
Changed #
CacheIndex.clockis no longer test-only (@visibleForTestingremoved) — accessed byStorageBlocandCacheCleanupUseCaseas part of clock wiring
1.0.0 - 2026-02-02 #
Stable Release #
First stable release of juice_storage.
Fixed #
- Clock wiring -
StorageBloc.clocknow propagates toCacheIndex, so TTL expiration checks use the overridden clock in tests - Background cleanup safety - Timer callback now guards against concurrent runs and catches errors instead of leaving unhandled async exceptions
- CacheCleanupEvent hang -
CacheCleanupEvent(runNow: false)no longer hangssendForResultdue to missing state emission - Init error preservation -
StorageState.lastErroris no longer unconditionally cleared at end of initialization; backend errors are preserved - CacheCleanupUseCase clock - Uses
cacheIndex.clock()instead of hardcodedDateTime.now()forlastCleanupAt
Changed #
- Updated dependency:
juice: ^1.3.0
Documentation #
- Fixed
secureDeleteAll()references →secureClearAll()(storage-backends, events-reference) - Fixed
StorageBackendStatus.allReady()→ explicit constructor (testing guide) - Updated dependency versions in getting-started guide
0.9.0 - 2025-01-12 #
Release Candidate #
Feature-complete release with comprehensive test coverage. API is stabilizing; 1.0.0 will follow after production validation.
Added #
- SQLite Use Case Tests - Comprehensive test coverage for SQLite operations (27 new tests)
- Platform Support Documentation - Added platform compatibility table to README
Changed #
- Updated dependency:
juice: ^1.2.0
Breaking Changes #
- Renamed
ResultEventtoStorageResultEvent- Resolves naming conflict with juice core'sResultEvent. If you subclassedResultEvent, update to extendStorageResultEventinstead. - Standardized Hive event parameters -
HiveOpenBoxEventandHiveCloseBoxEventnow useboxparameter instead ofboxNamefor consistency with other Hive events.- Before:
HiveOpenBoxEvent(boxName: 'cache') - After:
HiveOpenBoxEvent(box: 'cache')
- Before:
- Helper method parameter renamed -
hiveOpenBox(String boxName)is nowhiveOpenBox(String box)
Documentation #
- Added platform support matrix showing backend availability per platform
- Web limitations documented for SQLite and Secure Storage
0.8.0 - 2025-01-10 #
Added #
- StorageBloc - Unified BLoC for managing multiple storage backends
- Hive Support - Structured key-value storage with box management
- TTL-based caching with automatic lazy eviction on read
- Lazy box initialization
- SharedPreferences Support - Simple key-value storage
- TTL-based caching with lazy eviction
- Configurable key prefix
- SQLite Support - Relational database operations
- Raw SQL execution
- Typed insert/update/delete/query methods
- Per-table rebuild groups
- Secure Storage Support - Encrypted storage for sensitive data
- flutter_secure_storage integration
- No TTL (by design for security)
- Background Cleanup - Optional background task for proactive cache eviction
- Cache Index - Centralized TTL metadata tracking across backends
- Helper Methods - Convenient async methods on StorageBloc
- Rebuild Groups - Targeted widget rebuilds per backend/entity
- Event-Driven Architecture - Full Juice framework integration
- Cumulative Eviction Tracking - Track evictions by backend type
Documentation #
- Comprehensive README with badges and examples
- Complete documentation in
doc/folder:- Getting Started guide
- Storage Backends reference
- Events Reference
- Caching and TTL guide
- Testing guide
Package Publishing #
- Added LICENSE (MIT)
- Added pub.flutter-io.cn metadata (topics, funding, issue tracker)
- Added GitHub Sponsors funding link