work_db 1.3.0
work_db: ^1.3.0 copied to clipboard
A lightweight, cross-platform local database for Dart and Flutter. Simple key-value storage with collections, supporting Desktop, Web, and Mobile.
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.
1.3.0 - 2026-05-01 #
Added #
- Record Limit per Collection: New optional
maxRecordsPerCollectionparameter on all constructors (ClientWorkDb,ClientWorkDbLock,ClientWorkDbLockSync) and factory methods (WorkDbFactory,WorkDbConfig,WorkDb.memory/io/web)- When the limit is exceeded, the oldest records are automatically evicted
- Eviction uses
createdAttimestamps (null-safe: items without timestamps sort last) - Triggered on
create,createMultiple,createOrUpdate,createOrUpdateMultiple(async and sync) - Fully compatible with locking (
ClientWorkDbLock,ClientWorkDbLockSync)
testIWorkDbWithMaxRecords: New reusable test suite with 7 tests covering limit enforcement, oldest-first eviction,createOrUpdateedge cases, and sync API support
1.2.0 - 2026-03-24 #
Added #
- Synchronous API: All database operations are now available as synchronous methods via
IWorkDbSynccreateSync,createMultipleSync,updateSync,createOrUpdateSync,createOrUpdateMultipleSyncretrieveSync,retrieveMultipleSync,deleteSync,deleteCollectionSync,clearDatabaseSyncgetItemsInCollectionSync,getCollectionsSync
IWorkDbSync: New interface defining the complete synchronous database APIIWorkFileSystemSync: New interface for synchronous low-level file system operationsILockManagerSync: New interface for synchronous lock managementLockManagerSync: Synchronous file-based lock manager (mirrorsLockManager)tryAcquireSync,tryAcquireThrowSync,releaseSync,isLockedSync,clearAllLocksSync- Stale lock detection with configurable timeout
ClientWorkDbLockSync: ExtendsClientWorkDbLockwith thread-safe synchronous operations- Protects all
*Syncmethods withLockManagerSync - Both
ClientWorkDbLockSync(backend)andClientWorkDbLockSync.withWaitingMs(backend, waitingMs: n)constructors
- Protects all
testIWorkDbSync: Reusable test suite for synchronous implementations (mirrorstestIWorkDb)- Sync tests added for all implementations (Memory, Web, IO) in
all_implementations_test.dart
Changed #
ClientWorkDbnow implements bothIWorkDb(async) andIWorkDbSync(sync)- All built-in backends (
IoWorkDb,MemoryWorkDb,WebWorkDb) already exposeIWorkFileSystemSync
1.1.0 - 2026-02-02 #
Added #
- File-based Locking: Introducing
ClientWorkDbLockfor thread-safe concurrent access with automatic lock management- Lock acquisition with
tryAcquire()andtryAcquireThrow()methods - Automatic lock expiration detection (5000ms timeout)
- Stale lock cleanup with configurable timeout (
waitingMsparameter) - Lock information tracking (timestamp and user)
- Windows file lock error handling
- Lock acquisition with
- LockManager: New file-based lock manager implementation
- Lock files stored in parallel
./WorkDBLocksdirectory structure - ISO8601 timestamp-based expiration tracking
- Optional timeout-based stale lock detection
- Simple and timeout modes for flexibility
- Lock files stored in parallel
- LockAcquisitionException: New exception type for lock acquisition failures
- Inheritance-based Architecture: Refactored with
partandpart offor clean code separationClientWorkDb- Base class without locking (for non-concurrent scenarios)ClientWorkDbLock- Extends ClientWorkDb with full locking support- Eliminates null checks and improves maintainability
- Enhanced Testing: Added 22 comprehensive locking tests covering:
- Lock acquisition and release
- Multi-client concurrent access
- Stale lock detection and cleanup
- Lock timeout and expiration
- Error handling and lock recovery
Changed #
ClientWorkDbis now a lightweight base implementation without locking overhead- Users requiring thread-safety should use
ClientWorkDbLockinstead - Internal architecture improved with library-level
partdirectives
Improved #
- Better separation of concerns between locking and non-locking implementations
- More efficient for single-threaded or non-concurrent applications
- Comprehensive documentation for lock management
- 22 new tests ensuring lock correctness across scenarios
1.0.2 - 2026-01-20 #
Added #
- Introduced polymorphic Factory Pattern with dedicated input types (
IoWorkDbFactoryInput,WebWorkDbFactoryInput,MemoryWorkDbFactoryInput) for each implementation. - All examples, tests, and documentation now use the new factory pattern.
- All test suites aligned to the new pattern (202 tests, 100% pass).
Changed #
- Breaking change: All instantiation now requires input objects for factory methods.
- README and examples updated to reflect new usage.
Removed #
- Deprecated old static factory methods (
forIo,forWeb,forMemory,createIo,createWeb,createMemory).
1.0.0 - 2024-12-22 #
Added #
- Initial release
ClientWorkDb- Main database client implementationIoWorkDb- File system storage for Desktop/Server (Windows, macOS, Linux)WebWorkDb- localStorage-based storage for WebMemoryWorkDb- In-memory storage for testingWorkDbFactory- Factory methods for easy instantiation- Full CRUD operations: create, read, update, delete
- Batch operations: createMultiple, retrieveMultiple, createOrUpdateMultiple
- Collection management: getItemsInCollection, getCollections, deleteCollection
- Comprehensive test suite with 33 tests per implementation